Object's direction

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  10 October 2011
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?
 
  10 October 2011
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
 
  10 October 2011
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.
 
  10 October 2011
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
 
  10 October 2011
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.
 
  10 October 2011
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
 
Thread Closed share thread



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 vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:53 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.