11 November 2005  
KnowitAll
cg artist

Geometrical calculations : points, lines, planes : intersections, distances, angles
I am trying to collect the most usual functions for the geometrical calculations :
Intersection point, projection, distance, angle, ... Of course there are many Web sites about this, but I do not seek the mathematical formulas but functions 'readytouse' in maxscript. I start by giving the formulas which I know already. If you know other formulas do not hesitate to add them. Let's say that you have 4 points: pA=[ax,ay,az] pB=[bx,by,bz] pC=[cx,cy,cz] pD=[dx,dy,dz] With these points you can define a vector, a line, a plane. Vector: vAB=pBpA vAC=pCpA vCD=pDpC Vector Normalization : length vector = 1.0
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/NormalizedVector.html Cross Product :
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/CrossProduct.html Dot Product :
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/DotProduct.html line: A line can be defined :  by 2 points  or by 1 point and 1 vector Middle Point M of AB:
Point along AB : the point at 25% between A and B:
plane: A plane can be defined :  by 3 points  or by 1 point and 2 vectors  or by 1 point and 1 vector (the normal vector) Normal Vector : the vector perpendicular to the plane:
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/NormalVector.html line and point: PointLine Projection : find the point on the line AB which is the projection of the point C:
PointLine Distance : the distance between the line AB and the point C:
or
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/Point...imensional.html PointLine Inclusion : is this point on the line ?
or PointLine Distance <= tolerance distance (to be continued) 
11 November 2005  
Game Artist
portfolio
Bronson Mathews
Game Artist
Australia

nice stuff
takes me back to highschool math days.... 
03 March 2006  
KnowitAll
cg artist

line and line
line and line:
LineLine Intersection : intersection of two lines AB and CD:
or by using vectors:
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/LineLineIntersection.html LineLine Distance : distance between two skew lines
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/LineLineDistance.html LineLine // Distance : distance between two parallel lines use "PointLine Distance" : pApB is the first line and pC is a point of the second line LineLine Angle : angle between two lines:
or
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/LineLineAngle.html 
03 March 2006  
KnowitAll
cg artist

plane and point
plane and point:
PointPlane Projection : find the point on the plane ABC which is the projection of the point D
PointPlane Distance : find the distance between a plane and a point
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/PointPlaneDistance.html Last edited by prettyPixel : 03 March 2006 at 07:05 AM. 
03 March 2006  
KnowitAll
cg artist

plane and line
plane and line:
LinePlane Intersection : intersection between a line and a plane
This script is based on an original script of Joshua Newman. return 0 for parrallel (no intersections) results and 1 for coincident (infinate) results http://forums.cgsociety.org/showthread.php?t=290255 see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/LineP...tersection.html LinePlane Distance : distance between a plane and a line // use "PointPlane Distance" : where 'point' is a point of the line Vector perpendicular to a line into a Plane : the perpendicular of AB into the plane ABC
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/Perpendicular.html 
03 March 2006  
in 3D!
portfolio
Joshua Newman
Director
MESHROOM
London,
United Kingdom

Originally Posted by prettyPixel:
plane and line:
LinePlane Intersection : intersection between a line and a plane
This script is based on an original script of Joshua Newman. return 0 for parrallel (no intersections) results and 1 for coincident (infinate) results http://forums.cgsociety.org/showthread.php?t=290255 see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/LineP...tersection.html LinePlane Distance : distance between a plane and a line // use "PointPlane Distance" : where 'point' is a point of the line Vector perpendicular to a line into a Plane : the perpendicular of AB into the plane ABC
see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/Perpendicular.html Thanks for the aknowelgement PP. Still can't get around using the tolerence then eh? Great resource BTW, keep up the good work! J¬ __________________
www.joshuanewman.net 
03 March 2006  
Stealthy Tea Monkey
portfolio
Martin Brennand
VFX Artist
Melbourne,
Australia

This should be a sticky!
__________________
"There Really is No Secret" Martin Brennand  mocha Product Manager  Imagineer Systems 
03 March 2006  
KnowitAll
cg artist

Thanks guys
jman: The tolerance seems to work for me, but I use rather the function in cases where the line is not parallel to the plan. Can you give an example where the tolerance is an issue? Well, the continuation: 
03 March 2006  
KnowitAll
cg artist

plane and plane
plane and plane:
PlanePlane Intersection : find the line which is the intersection of 2 planes p1 : a point of the plane 1 n1 : the normal of the plane 1
I think that it is not the easiest solution. If you know a better means... see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/Plane...tersection.html Plane perpendicular to a Plane and a Line : find the plane which is perpendicular to the plane n and to the line AB It's the plane ABC where C=A+n see also : Eric W. Weisstein. From MathWorldA Wolfram Web Resource. http://mathworld.wolfram.com/ParallelPlanes.html PlanePlane Angle : find the angle between two planes n1 and n2 (normals)

04 April 2006  
in 3D!
portfolio
Joshua Newman
Director
MESHROOM
London,
United Kingdom

Originally Posted by prettyPixel:
Can you give an example where the tolerance is an issue?
Yes, if the results are parrallel or coincident the rounding error tells the function from telling which! J¬ __________________
www.joshuanewman.net Last edited by jman : 04 April 2006 at 12:41 PM. 
04 April 2006  
KnowitAll
portfolio
James Haywood
Senior Technical Artist
Bungie Studios
Seattle,
USA

Hey PP, just wondering if you're done adding to this thread. I want to put together a word doc containing all these functions, but wanted to wait until you were fiinished.

04 April 2006  
KnowitAll
portfolio
James Haywood
Senior Technical Artist
Bungie Studios
Seattle,
USA

I've got a math question, and this seems like a good place to ask. I tried digging through Mathworld, but it's way over my head.
I'd like to be able to find a point on an arc defined by the end point of an object rotated around it's pivot, along a specific axis. For example, let's say there's a bone object with a end bone as it's child. If I rotate the parent bone around it's Y axis 10 degrees, the end bone is now at a new position. What's the formula for finding that position? This page at Mathworld describes what I'm talking about, except in 2D: http://mathworld.wolfram.com/Arc.html 
04 April 2006  
Stealthy Tea Monkey
portfolio
Martin Brennand
VFX Artist
Melbourne,
Australia

Originally Posted by JHaywood:
I've got a math question, and this seems like a good place to ask. I tried digging through Mathworld, but it's way over my head.
I'd like to be able to find a point on an arc defined by the end point of an object rotated around it's pivot, along a specific axis. For example, let's say there's a bone object with a end bone as it's child. If I rotate the parent bone around it's Y axis 10 degrees, the end bone is now at a new position. What's the formula for finding that position? This page at Mathworld describes what I'm talking about, except in 2D: http://mathworld.wolfram.com/Arc.html That should be a straight trig calculation where (skeleton code):
I'm a little hazy on the Z phi stuff, so somebody correct me if i'm wrong! __________________
"There Really is No Secret" Martin Brennand  mocha Product Manager  Imagineer Systems Last edited by erilaz : 04 April 2006 at 03:58 AM. 
04 April 2006  
KnowitAll
cg artist

Originally Posted by JHaywood:
Hey PP, just wondering if you're done adding to this thread. I want to put together a word doc containing all these functions, but wanted to wait until you were fiinished.
I think that the essential formulae are there but anyone can add some more. The possibilities are illimited. Here is an example: this script discovers if a line intersects a sphere. It returns true or false.
I use the projection of a point on a plane which passes by the sphere center. If the distance between this point and the center is lower or equal to the sphere radius then the line intersects the sphere. It's based on the function 'PointPlane Projection' . Another way of going farther is to write the same functions but on objects like triangular faces or segments. For example find the position of a line that intersects a mesh face (not a plane). The case is more restricted. 
reply share thread 
«
Previous Thread

Next Thread
»


