public void rotate ( Quaternion rotation , Point3D pivot ) { Point3D currentPivot = getPivot ( ) ; // Update the plane equation according // to the desired normal (computed from // the identity vector and the rotations). Transform3D m = new Transform3D ( ) ; m . setRotation ( rotation ) ; Vector3f v = new Vector3f ( this . getEquationComponentA ( ) , this . getEquationComponentB ( ) , this . getEquationComponentC ( ) ) ; m . transform ( v ) ; this . setEquationComponentA ( v . getX ( ) ) ; this . setEquationComponentB ( v . getY ( ) ) ; this . setEquationComponentC ( v . getZ ( ) ) ; if ( pivot == null ) { // a.x + b.y + c.z + d = 0 // where (x,y,z) is the translation point this . setEquationComponentD ( - ( this . getEquationComponentA ( ) * currentPivot . getX ( ) + this . getEquationComponentB ( ) * currentPivot . getY ( ) + this . getEquationComponentC ( ) * currentPivot . getZ ( ) ) ) ; } else { // Compute the new point Point3f nP = new Point3f ( currentPivot . getX ( ) - pivot . getX ( ) , currentPivot . getY ( ) - pivot . getY ( ) , currentPivot . getZ ( ) - pivot . getZ ( ) ) ; m . transform ( nP ) ; nP . setX ( nP . getX ( ) + pivot . getX ( ) ) ; nP . setY ( nP . getY ( ) + pivot . getY ( ) ) ; nP . setZ ( nP . getZ ( ) + pivot . getZ ( ) ) ; // a.x + b.y + c.z + d = 0 // where (x,y,z) is the translation point this . setEquationComponentD ( - ( this . getEquationComponentA ( ) * nP . getX ( ) + this . getEquationComponentB ( ) * nP . getY ( ) + this . getEquationComponentC ( ) * nP . getZ ( ) ) ) ; } clearBufferedValues ( ) ; }
Rotate the plane around the given pivot point .