# Object's direction

 Thread Tools Display Modes
 10 October 2011 cppgraphics Veteran portfolio Sureshkumar India Object's direction Hello folks, How to find a object's direction in MEL? whether in it is in X direction or Z direction from current position? If any formula should be used or what? share quote
 10 October 2011 NaughtyNathan HighEnd3D deserter   Naughty Nathan Technical Artist Sony SCEE Liverpool Manchester, United Kingdom If you are refering to an objects direction as being the vector of it's local or world X, Y or Z axis, you could just extract the X, Y or Z axis from the objects local or world matrix. Assuming the matrix is got as 16 floats (i.e. via xform or getAttr) components [0:2] are the X axis vector, [4:6] are the Y axis vector and [8:10] are the Z axis vector. :nathaN share quote
 10 October 2011 cppgraphics Veteran portfolio Sureshkumar India Originally Posted by NaughtyNathan: If you are refering to an objects direction as being the vector of it's local or world X, Y or Z axis, you could just extract the X, Y or Z axis from the objects local or world matrix. Assuming the matrix is got as 16 floats (i.e. via xform or getAttr) components [0:2] are the X axis vector, [4:6] are the Y axis vector and [8:10] are the Z axis vector. :nathaN Hi nathan, I need to find the world position only. Fox example, Locator(A), plane(B) are the two objects I got. A is at Orgin. B will be in any(+x,-x,+z-z) direction from A. Based on the distance between two objects and the direction Im adding some lights on the plane. To calulate distance my first component is Y and the second one is X or Z. So if I know the locator's position from the plane I can decide X or Y to pass it. hope you got my problem. share quote
 10 October 2011 NaughtyNathan HighEnd3D deserter   Naughty Nathan Technical Artist Sony SCEE Liverpool Manchester, United Kingdom sorry dude, no. I have no idea what your are talking about here. :( Maybe you need to describe your problem a little more clearly, or provide a diagram..? I have no idea whether you want direction or position: Quote: How to find a object's direction in MEL? ... I need to find the world position only. :nathaN share quote
 10 October 2011 cppgraphics Veteran portfolio Sureshkumar India Originally Posted by NaughtyNathan: I have no idea whether you want direction or position: Nathan, I just need the direction, sorry for the confused edition . In the picture A is located in -Z direction from B. Now I know the direction so I can calculate the distance by using Y and -Z values of both object's position. what if the A located in Z or X or -X from B, Is there any way to find the direction easily rather than many calculations? Once I find the direction then I can find the distance between two objects. heres the link of my example screen shot. share quote
 10 October 2011 mlefevre Expert   ... United Kingdom Originally Posted by cppgraphics: Once I find the direction then I can find the distance between two objects. The distance tool under 'Create > Measure Tools > Distance Tool' can give you the distance between two objects. There's also the distanceBetween node that uses two objects positions to determine distance. You can find the world space positions of two objects, subtract one from the other to obtain the vector (doesn't matter which order you subtract) then use the mag command. ``````string \$sel[] = `ls -sl`; vector \$A = `xform -q -ws -translation \$sel[0]`; vector \$B = `xform -q -ws -translation \$sel[1]`; float \$dist = mag(\$A - \$B);`````` __________________ vimeo blog share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.