bnvm

01-08-2005, 07:12 AM

I've been experimenting for a while trying to get a vector for the local z axis of an object as it rotates. So far I haven't had any luck so far. Any suggestions would be very helpful. Thanks in advance.

View Full Version : Vector for local z axis

bnvm 01-08-2005, 07:12 AM I've been experimenting for a while trying to get a vector for the local z axis of an object as it rotates. So far I haven't had any luck so far. Any suggestions would be very helpful. Thanks in advance. |

bnvm

01-08-2005, 07:35 AM

never mind found it. It is just the .dir property of the object just in case any one else wants to know.

-bnvm

-bnvm

bnvm

01-08-2005, 07:49 AM

Having solved one problem I have come across another. I want to fire rays from the pivot of and object along its local x axis and varing angles. for example firing 10 rays from 0 to 180 degrees about the local x axis. Any suggestions on how to do this would be great.

-bnvm

-bnvm

Bobo

01-08-2005, 09:07 AM

Having solved one problem I have come across another. I want to fire rays from the pivot of and object along its local x axis and varing angles. for example firing 10 rays from 0 to 180 degrees about the local x axis. Any suggestions on how to do this would be great.

-bnvm

Take a look at the example "How do I rotate a vector around the Z axis?" in the MAXScript Reference 7.0. It rotates an arbitrary vector about the world Z axis.

In your case, you would define a vector [1,0,0] (X normal vector), do the same as in the example, then transform the stand-in object representing the ray into the local space of your object by multilpying with its .transform property.

theObj = $Teapot01 --assuming your object to define a local space is a teapot

theV = [1,0,0]

for a = 0 to 180 by 10 do

(

rm = rotateZMatrix a

theRotV = theV * rm

c = cylinder radius:1 height:100

c.dir = theRotV

c.transform *= theObj.transform

)

This creates 10 cylinders pointing from 0 to 180 degrees in Teapot01's local space starting at X axis [1,0,0] and ending at -X axis [-1,0,0].

If you want to do this "virtually", you would have to work with matrices all the way, creating a matrix from the X normal vector, rotating it about world Z from 0 to 180 degrees and then transforming it into the local space. Finally, build a Ray value out of the translation and the Z axis of the resulting matrix:

theObj = $Teapot01

theTM = matrixFromNormal [1,0,0]

for a = 0 to 180 by 10 do

(

rm = rotateZMatrix a

theRotTM = (theTM * rm) * theObj.transform

theRay = Ray theRotTM.row4 theRotTM.row3 --the ray points along the X to -X in local space

)

-bnvm

Take a look at the example "How do I rotate a vector around the Z axis?" in the MAXScript Reference 7.0. It rotates an arbitrary vector about the world Z axis.

In your case, you would define a vector [1,0,0] (X normal vector), do the same as in the example, then transform the stand-in object representing the ray into the local space of your object by multilpying with its .transform property.

theObj = $Teapot01 --assuming your object to define a local space is a teapot

theV = [1,0,0]

for a = 0 to 180 by 10 do

(

rm = rotateZMatrix a

theRotV = theV * rm

c = cylinder radius:1 height:100

c.dir = theRotV

c.transform *= theObj.transform

)

This creates 10 cylinders pointing from 0 to 180 degrees in Teapot01's local space starting at X axis [1,0,0] and ending at -X axis [-1,0,0].

If you want to do this "virtually", you would have to work with matrices all the way, creating a matrix from the X normal vector, rotating it about world Z from 0 to 180 degrees and then transforming it into the local space. Finally, build a Ray value out of the translation and the Z axis of the resulting matrix:

theObj = $Teapot01

theTM = matrixFromNormal [1,0,0]

for a = 0 to 180 by 10 do

(

rm = rotateZMatrix a

theRotTM = (theTM * rm) * theObj.transform

theRay = Ray theRotTM.row4 theRotTM.row3 --the ray points along the X to -X in local space

)

CGTalk Moderation

01-20-2006, 10:00 AM

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.