类 Plane
- java.lang.Object
-
- org.meteoinfo.chart.jogl.pipe.Plane
-
public class Plane extends java.lang.Objectclass for a 3D plane with normal vector (a,b,c) and a point (x0,y0,z0) ax + by + cz + d = 0, where d = -(ax0 + by0 + cz0) ported from C++ code by Song Ho Ahn (song.ahn@gmail.com)
-
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 floatgetD()Get dfloatgetDistance(org.joml.Vector3f point)compute the shortest distance from a given point P to the plane Note: The distance is signed.org.joml.Vector3fgetNormal()Get normalorg.joml.Vector3fintersect(Line line)find the intersect point // substitute a point on the line to the plane equation, then solve for alpha // a point on a line: (x0 + x*t, y0 + y*t, z0 + z*t) // plane: a*X + b*Y + c*Z + d = 0 // // a*(x0 + x*t) + b*(y0 + y*t) + c*(z0 + z*t) + d = 0 // a*x0 + a*x*t + b*y0 + b*y*t + c*z0 + c*z*t + d = 0 // (a*x + b*x + c*x)*t = -(a*x0 + b*y0 + c*z0 + d) // // t = -(a*x0 + b*y0 + c*z0 + d) / (a*x + b*x + c*x)Lineintersect(Plane rhs)find the intersection line of 2 planes // P1: N1 dot p + d1 = 0 (a1*X + b1*Y + c1*Z + d1 = 0) // P2: N2 dot p + d2 = 0 (a2*X + b2*Y + c2*Z + d2 = 0) // // L: p0 + a*V where // V is the direction vector of intersection line = (a1,b1,c1) x (a2,b2,c2) // p0 is a point, which is on the L and both P1 and P2 as well // // p0 can be found by solving a linear system of 3 planes // P1: N1 dot p + d1 = 0 (given) // P2: N2 dot p + d2 = 0 (given) // P3: V dot p = 0 (chosen where d3=0) // // Use the formula for intersecting 3 planes to find p0; // p0 = ((-d1*N2 + d2*N1) x V) / V dot VbooleanisIntersected(Line line)determine if it intersects with the linebooleanisIntersected(Plane plane)determine if it intersects with the other planevoidnormalize()normalize divide each coefficient by the length of normal
-
-
-
方法详细资料
-
getNormal
public org.joml.Vector3f getNormal()
Get normal- 返回:
- Normal
-
getD
public float getD()
Get d- 返回:
- d
-
getDistance
public float getDistance(org.joml.Vector3f point)
compute the shortest distance from a given point P to the plane Note: The distance is signed. If the distance is negative, the point is in opposite side of the plane. D = (a * Px + b * Py + c * Pz + d) / sqrt(a*a + b*b + c*c) reference: www.songho.ca/math/plane.html- 参数:
point- The point- 返回:
- Distance
-
normalize
public void normalize()
normalize divide each coefficient by the length of normal
-
intersect
public org.joml.Vector3f intersect(Line line)
find the intersect point // substitute a point on the line to the plane equation, then solve for alpha // a point on a line: (x0 + x*t, y0 + y*t, z0 + z*t) // plane: a*X + b*Y + c*Z + d = 0 // // a*(x0 + x*t) + b*(y0 + y*t) + c*(z0 + z*t) + d = 0 // a*x0 + a*x*t + b*y0 + b*y*t + c*z0 + c*z*t + d = 0 // (a*x + b*x + c*x)*t = -(a*x0 + b*y0 + c*z0 + d) // // t = -(a*x0 + b*y0 + c*z0 + d) / (a*x + b*x + c*x)- 参数:
line- The line- 返回:
- Intersect point
-
intersect
public Line intersect(Plane rhs)
find the intersection line of 2 planes // P1: N1 dot p + d1 = 0 (a1*X + b1*Y + c1*Z + d1 = 0) // P2: N2 dot p + d2 = 0 (a2*X + b2*Y + c2*Z + d2 = 0) // // L: p0 + a*V where // V is the direction vector of intersection line = (a1,b1,c1) x (a2,b2,c2) // p0 is a point, which is on the L and both P1 and P2 as well // // p0 can be found by solving a linear system of 3 planes // P1: N1 dot p + d1 = 0 (given) // P2: N2 dot p + d2 = 0 (given) // P3: V dot p = 0 (chosen where d3=0) // // Use the formula for intersecting 3 planes to find p0; // p0 = ((-d1*N2 + d2*N1) x V) / V dot V- 参数:
rhs- The plane- 返回:
- Intersect line
-
isIntersected
public boolean isIntersected(Line line)
determine if it intersects with the line- 参数:
line- The line- 返回:
- Intersect or not
-
isIntersected
public boolean isIntersected(Plane plane)
determine if it intersects with the other plane- 参数:
plane- The plane- 返回:
- Intersect or not
-
-