HuaMuLan

03-10-2009, 07:47 PM

Is Maxscript provide some convienient way to check if a given axis (such as Y) is pointing up?

View Full Version : How to check a given axis if it's pointing straight up.

HuaMuLan 03-10-2009, 07:47 PM Is Maxscript provide some convienient way to check if a given axis (such as Y) is pointing up? |

Moosley

03-11-2009, 10:09 AM

You could probably use the dot product of the two vectors to work it out:

dot <Point3> [0,0,1]

where <Point3> is the point3 vector of the axis you want to check, eg $.transform.row2

The closer the result is to 1.0 then the closer to 'Up' the vector is pointing. If the result is negative then the vector is pointing 'Down'. If the result is 0.0 then the two vectors are perpendicular.

dot <Point3> [0,0,1]

where <Point3> is the point3 vector of the axis you want to check, eg $.transform.row2

The closer the result is to 1.0 then the closer to 'Up' the vector is pointing. If the result is negative then the vector is pointing 'Down'. If the result is 0.0 then the two vectors are perpendicular.

j-man

03-11-2009, 11:16 AM

Hi,

This may be a bit sloppy, but it should work

$myobject.dir==[0,0,1]

Regards,

Josh.

This may be a bit sloppy, but it should work

$myobject.dir==[0,0,1]

Regards,

Josh.

Moosley

03-11-2009, 11:30 AM

That will only tell you where the Z_Axis of the object is pointing, and due to floating point errors won't always work. A tiny variance in the vector in memory means that the expression will evaluate to false, even though in the listener it prints out correctly, though I've got around this in the past by converting the value to a string first and comparing that.

HuaMuLan

03-11-2009, 11:51 AM

I did find the answer . Which did give me a slight shock .

Hua*MuLan~ which is me

http://www.maxforums.org/thread.aspx?tid=559656

Thank you for involving.

Hua*MuLan~ which is me

http://www.maxforums.org/thread.aspx?tid=559656

Thank you for involving.

j-man

03-12-2009, 03:08 PM

That will only tell you where the Z_Axis of the object is pointing, and due to floating point errors won't always work. A tiny variance in the vector in memory means that the expression will evaluate to false, even though in the listener it prints out correctly, though I've got around this in the past by converting the value to a string first and comparing that.

yes! it's true! it's very sloppy! whaaa!! :cry:

You're correct, using the dot product is the best way.

J < :

yes! it's true! it's very sloppy! whaaa!! :cry:

You're correct, using the dot product is the best way.

J < :

CGTalk Moderation

03-12-2009, 03:08 PM

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.

vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.