PDA

View Full Version : MEL: MATH: 2 Points to Normal


MasterZ
05-03-2006, 12:47 AM
I am looking to convert two 3D world space points to a (3 part) normal.
Is there any simple tool? MEL tool?

I am currently struggling with this route...
get the offsets XYZ
you need the rise and run to calculate the degrees
and so Fractions like XY= X / Y
for making the degrees via tan() function for tangents (I thought it was cot which does not exist in MEL).
result should be in radians.
next rad_to_deg
and them something other then divide by 360 maybe ((XYdeg/180)-1) or something to do with getting it to a range or -1 to +1 for X, Y and Z.

Any input at this point would be great, I'm suffering temporary brain freeze.

I realize this is more a math question, I don't want to create nodes to solve this that's likely too slow, but I'm open to suggestions.

MasterZ
05-03-2006, 11:19 AM
Now it looks like the points offsets in a vector normailized with the 'unit command' is enough to get the correct normal from two points.

othrewise on should note it was atan not tan to get the degree and you need to incorporate the quadrants with if(s) for ++ +- -- -+ by adding either 180 or 360 depending on which quadrant your calculating degrees from atan with.

pgraham
05-05-2006, 02:07 AM
all you need to do is subtract one from the other and then normalize (unit).

for future reference,
cot is 1/tan.
atan2 will give you angles in all 4 quadrants.

MasterZ
05-06-2006, 11:25 AM
Totally useful information I'm learning (cool), you are a valued member thanks for the reply.

CGTalk Moderation
05-06-2006, 11:25 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.