include "./Tuple3d" import "JavaBuiltin" as Java importJava "javax.vecmath.Vector3d" where // Immutable mapping data Vector3d dot :: Vector3d -> Vector3d -> Double length :: Vector3d -> Double lengthSquared :: Vector3d -> Double angle :: Vector3d -> Vector3d -> Double @JavaName "" createVector3d :: Double -> Double -> Double -> Vector3d @JavaName "" copyVector3d' :: Tuple3d -> Vector3d @JavaName "" defaultVector3d :: Vector3d // Mutable mapping data MVector3d @JavaName cross crossM :: MVector3d -> Vector3d -> Vector3d -> () @JavaName normalize normalizeM :: MVector3d -> () @JavaName normalize normalizeM2 :: MVector3d -> Vector3d -> () @JavaName dot dotM :: MVector3d -> MVector3d -> Double @JavaName length lengthM :: MVector3d -> Double @JavaName lengthSquared lengthSquaredM :: MVector3d -> Double @JavaName angle angleM :: MVector3d -> MVector3d -> Double @JavaName "" createMVector3d :: Double -> Double -> Double -> MVector3d @JavaName "" copyMVector3d' :: Tuple3d -> MVector3d @JavaName "" defaultMVector3d :: MVector3d @private applyMOp :: (MVector3d -> ()) -> ( MVector3d) -> Vector3d applyMOp op gen = runProc let z = gen op z in freeze z normalize :: Vector3d -> Vector3d normalize v = applyMOp normalizeM (copyMVector3d (asTuple v)) cross :: Vector3d -> Vector3d -> Vector3d cross x y = applyMOp (\z -> crossM z x y) defaultMVector3d freeze :: MVector3d -> Vector3d freeze = Java.unsafeCoerce instance Tuple3dClass Vector3d instance MTuple3dClass MVector3d copyVector3d :: Tuple3dClass a => a -> Vector3d copyVector3d = copyVector3d' . asTuple copyMVector3d :: Tuple3dClass a => a -> MVector3d copyMVector3d = copyMVector3d' . asTuple