Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Using PDL for rotations

by pc88mxer (Vicar)
on Apr 29, 2008 at 16:38 UTC ( [id://683519]=note: print w/replies, xml ) Need Help??


in reply to Using PDL for rotations

t_rot takes a single argument, so you need to use (but see update below):
$e = t_rot([45,45,45]);
The other thing is that $e will be a transform object which requires you to use it like this:
$d = $e->apply($c);
The final thing is that matrix multiplication is the x operator whereas * is component-wise multiplication.

Update: There's a bug in the code/documentation for t_rot. The work-around is to use t_linear and also specify a dims argument:

$e = t_linear({ rot => [45,45,45], dims => 3});
The problem can be demonstrated by setting $PDL::Transform::debug = 1;:
$PDL::Transform::debug = 1; $e = t_linear({ rot => [45,45,45] }); # the above will emit: # PDL::Transform::Linear: assuming 2-D transform (set dims option to + change)

Replies are listed 'Best First'.
Re^2: Using PDL for rotations
by etj (Deacon) on Jun 07, 2022 at 02:53 UTC
    Note from THE FUTURE: this bug was in fact still there! And impressively, there was not a single test for any of the rotation stuff. Now there is a single test, which also caught another recently-introduced bug. The code will now use the number of elements in the rotation if neither dims nor matrix are supplied.

    Both bugs now have fixes, which will be in PDL 2.081.

Re^2: Using PDL for rotations
by Anonymous Monk on Apr 29, 2008 at 19:09 UTC
    Okay one more question, upon doing rotations perl some times returns infitesmaly small numbers instead of zero (where it should be zero, as I check them my-self). Is there a simple way to have perl return them zero by changing precision somehow? Thanks...
      Floating-point math can get ugly little rounding errors. You're seeing them here.

      No need to set any precision, simply make sure the magnitude of the values are above some $eps (epsilon) or set them to zero.

      Like so:  $pdl = $pdl * ( (abs $pdl) > $eps);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://683519]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-23 13:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found