Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I was digging through some bit-rotted PDL::Graphics::TriD stuff to finish/fix it, and looked at PDL::Graphics::TriD::Logo. It was intended to be used with the non-functional-right-now PDL VRML support, in particular VRML's IndexedFaceSet feature. It had 3D point coordinates, then triplets of indexes into those to describe triangles.

Gripped - nay, seized - by a desire to see what the logo looked like, I needed to turn that into something the current TriD code can show me. I knew line3d could take a set of 4-point tuples to draw triangles if the 4th point was the same as the 1st. But how to turn points+indexes into that?

I often say that in PDL, the "right" solution to problems involves slices and dimension-mangling. This was no exception!

use PDL::Graphics::TriD; use PDL::Graphics::TriD::Logo; $p = $PDL::Graphics::TriD::Logo::POINTS; # dims: xyz, i $i = $PDL::Graphics::TriD::Logo::FACES; # dims: i1to3, ntriangles # 1: duplicate 0-th index onto end of each vector completing triangle $i = $i->append($i->slice('0')); # change to i1to3to1 # 2: flatten indices, slice points with those, restore 4-tuples shape $tri = $p->slice(':',$i->clump(-1))->splitdim(1,$i->dim(0)); line3d($tri); # visualise
Coda: the logo is just "PDL" in a serif font, given "depth" as if in a stick of rock.

I'm intending to update the VRML support to:

  1. generalise that plus the OpenGL support of each specific thing (lines, points, etc) to go via an intermediate description to make this easy;
  2. work at all;
  3. switch it to use X3D;
  4. use that to generate updated 3d demos for the PDL website.
If anyone wants to help, please say so!

In reply to IndexedFaceSet to 3D lines in two lines of PDL by etj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-26 00:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found