Method to get the Hessian normal form of Plane geometries

Hello!
To get the Hessian representation of a Plane geometry, I go through these stages:

  1. Sample a random point on the surface (around 10 lines of code)
  2. Get the world normals of the mesh (around 4 lines of code)
  3. Calculate the normal.x, normal.y, normal.z and the constant p for the Plane constructor (around 10 lines of code)

So it takes around 24 lines of code to get the Plane object from a Plane mesh. I believe it would be really useful to have a one-liner (Plane.fromPlaneGeometry() or something like that) since the Plane class can be really handy when estimating collisions etc.

Thanks!

Author: Fantashit

1 thought on “Method to get the Hessian normal form of Plane geometries

  1. world normal = face.normal.applyMatrix4(newTHREE.Matrix4().extractRotation(mesh.matrixWorld))

    Avoid calling new or clone() in hot methods.

    To get you started, here is a first-cut at a method to do what you want. It is sightly more complicated if the mesh has a parent object.

    THREE.Plane.prototype.setFromPlaneMesh = function ( mesh ) {
    
    	var normal = new THREE.Vector3();
    
    	return function setFromPlaneMesh( mesh ) {
    
    		// assumes mesh is a child of the scene
    
    		normal.set( 0, 0, 1 ).applyQuaternion( mesh.quaternion );
    
    		this.setFromNormalAndCoplanarPoint( normal, mesh.position );
    
    	};
    
    }();

Comments are closed.