Frage

In a given domain, I need to represent mathematical plane in 3D space, so I intend to create a Plane3D class.

I would also have Point3D, Vector3D, Ray3D, and so on. Main use case would be to test/find line-plane intersections, line-plane angles, and other geometric operations.

Question is:

Which would be a good, canonical, computation-friendly way to implement plane definition in a class?

Most obvious candidates would be "point-normal" form, with six numeric parameters (three coordinates for the point, three for the vector) and "general (algebraic) form", with four numeric parameters (one coefficient per coordinate and one constant). Is one of them computationally preferrable?

Also, is there any open source, high level 3D Geometry library already implementing this class, which would be worth taking a look for inspiration?

OBS: Since .NET has System.Windows.Media.Media3D library with some useful classes, most probably I'll implement this in C#, taking advantage of Point3D and Vector3D structs, but I think the question is language-agnostic.

War es hilfreich?

Lösung

I'd go for what you call algebraic form. A point (x,y,z) is on a plane (a,b,c,d) if a*x+b*y+c*z+d=0.

To intersect that plane with a line spanned by (x1,y1,z1) and (x2,y2,z2), compute s1=a*x1+b*y1+c*z1+d and s2=a*x2+b*y2+c*z2+d. Then your point of intersection is defined by

x=(s1*x2-s2*x1)/(s1-s2)
y=(s1*y2-s2*y1)/(s1-s2)
z=(s1*z2-s2*z1)/(s1-s2)

To compute the angle between a line and a plane, simply compute

sin(α)=(a*x+b*y+c*z)/sqrt((a*a+b*b+c*c)*(x*x+y*y+z*z))

where (a,b,c) represents the normal vector in this representation of the plane, and (x,y,z) is the direction vector of the line, i.e. (x2-x1,y2-y1,z2-z1). The equation is essentially a normalized dot product, and as such is equivalent to the cosine between the two vectors. And since the normal vector is perpendicular to the plane, and sine and cosine differ by 90°, this means that you get the sine of the angle between the line and the plane itself.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top