Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?

by salva (Abbot)
on Jun 26, 2012 at 21:51 UTC ( #978519=note: print w/replies, xml ) Need Help??

in reply to Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?

Math::Vector::Real provides the method rotate_3d that already does what you want:
use Math::Vector::Real; $offset = V($x, $y, $z); $p_rotated_1deg = $axis->rotate_3d(1*$pi/180, $p - $offset) + $offset;

Replies are listed 'Best First'.
Re^2: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?
by fraizerangus (Sexton) on Jun 28, 2012 at 10:11 UTC
    I've used this module before and been very impressed with it :) but where would you input the line unit vector to state the point at which you'd like to rotate? thanks
      The line is defined by two vectors:

      The first vector defines the direction of the line; it corresponds to $axis on the code from my previous post.

      The second vector indicates the positions of some point of the line relative to the origin (it can be any point on the line). It is what I have called $offset.

      The rotate_3d performs the rotation around a line passing through the origin and with the given direction, so to use it to rotate a vector $p around a line that does not pass through the origin, we have to perform a translation, rotate the vector and undo the translation.

      In practice, that means, subtracting the vector $offset to $p, performing the rotation, and then adding $offset to the resulting value.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://978519]
[Eily]: I still don't understand how the Turkish AA fit into the German+Czech joke though :P
[LanX]: new Firefox + cb sidebar do random auto expand on submit
[LanX]: probably need to start pm discussion
[LanX]: they have a constitutional referendum in turkey, kind of "do you want a dictator" and everybody opting no gets problems ...
[Corion]: LanX: Random Auto Expand?
[Corion]: LanX: Well, everybody opting "yes" will also get problems. The question is more like "Do you want problems now or problems later?"
[LanX]: and the AA had posters with a big say NO with a small "to alcohol"
[ambrus]: LanX: is it the kind of free and secret vote where there's only one box you can check?

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-03-27 12:14 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.