{- |
Various facilities for dealing with vectors, vector spaces and coordinate axies generically.
-}{-# LANGUAGE FlexibleContexts, MultiParamTypeClasses, TypeFamilies #-}moduleData.Vector.FancywhereimportData.Vector.ClassimportData.Vector.V1importData.Vector.V2importData.Vector.V3importData.Vector.V4-- * Vector spaces{- |
This class deals with any type that has a spatial dimensionallity.
This includes coordinate transforms, bounding boxes, and so on.
Null instances are provided for all the vector types. (E.g.,
@Point Vector3 = Vector3@.)
-}class(Vector(Pointx))=>HasSpacexwhere-- | Give the appropriate kind of vector for this type.typePointx::*instanceHasSpaceVector1wheretypePointVector1=Vector1instanceHasSpaceVector2wheretypePointVector2=Vector2instanceHasSpaceVector3wheretypePointVector3=Vector3instanceHasSpaceVector4wheretypePointVector4=Vector4-- * Vector axies-- | The X-axis (first axis).dataAxisX=AxisXderivingShow-- | The Y-axis (second axis).dataAxisY=AxisYderivingShow-- | The Z-axis (third axis).dataAxisZ=AxisZderivingShow-- | The W-axis (fourth axis).dataAxisW=AxisWderivingShow-- | Class for generically reading/writing vector coordinates.classVectorAxisvectoraxiswhere-- | Read from the specified coordinate axis.get_coord::axis->vector->Scalar-- | Replace the existing value of the given coordinate axis.set_coord::axis->Scalar->vector->vectorinstanceVectorAxisVector1AxisXwhereget_coord_=v1xset_coord_x_=Vector1xinstanceVectorAxisVector2AxisXwhereget_coord_=v2xset_coord_xv=v{v2x=x}instanceVectorAxisVector3AxisXwhereget_coord_=v3xset_coord_xv=v{v3x=x}instanceVectorAxisVector4AxisXwhereget_coord_=v4xset_coord_xv=v{v4x=x}instanceVectorAxisVector2AxisYwhereget_coord_=v2yset_coord_yv=v{v2y=y}instanceVectorAxisVector3AxisYwhereget_coord_=v3yset_coord_yv=v{v3y=y}instanceVectorAxisVector4AxisYwhereget_coord_=v4yset_coord_yv=v{v4y=y}instanceVectorAxisVector3AxisZwhereget_coord_=v3zset_coord_zv=v{v3z=z}instanceVectorAxisVector4AxisZwhereget_coord_=v4zset_coord_zv=v{v4z=z}instanceVectorAxisVector4AxisWwhereget_coord_=v4wset_coord_wv=v{v4w=w}-- * Vector projection{- |
This class enables you to take a vector with N dimensions and
project it into an N+1 dimensional space (and also take the inverse
projection to get back again).
-}class(Vectorv,Vector(ProjectTov))=>Projectvwhere-- | The next-largest vector type. (E.g., 'ProjectTo' 'Vector2' = 'Vector3'.)typeProjectTov::*-- | Reduce number of dimensions by one. (Return the dropped dimension as a @Scalar@.)orthographic_down::ProjectTov->(v,Scalar)-- | Increase number of dimensions by one. (Supply value for new dimension as a @Scalar@.)orthographic_up::(v,Scalar)->ProjectTov-- | Perspective-project to N-1 dimensions. (Also return the distance from the camera as a @Scalar@.)perspective_down::ProjectTov->(v,Scalar)-- | Inverse-perspective project into N+1 dimension. (Supply the distance from the camera as a @Scalar@.)perspective_up::(v,Scalar)->ProjectTovinstanceProjectVector1wheretypeProjectToVector1=Vector2orthographic_down(Vector2xy)=(Vector1x,y)orthographic_up(Vector1x,y)=(Vector2xy)perspective_down(Vector2xy)=(Vector1(x/y),y)perspective_up(Vector1x,y)=(Vector2(x*y)y)instanceProjectVector2wheretypeProjectToVector2=Vector3orthographic_down(Vector3xyz)=(Vector2xy,z)orthographic_up(Vector2xy,z)=(Vector3xyz)perspective_down(Vector3xyz)=(Vector2(x/z)(y/z),z)perspective_up(Vector2xy,z)=(Vector3(x*z)(y*z)z)instanceProjectVector3wheretypeProjectToVector3=Vector4orthographic_down(Vector4xyzw)=(Vector3xyz,w)orthographic_up(Vector3xyz,w)=(Vector4xyzw)perspective_down(Vector4xyzw)=(Vector3(x/w)(y/w)(z/w),w)perspective_up(Vector3xyz,w)=(Vector4(x*w)(y*w)(z*w)w)