mischief-math
Safe HaskellNone
LanguageGHC2024

Mischief.Math

Synopsis

Dependencies

How to Use

This library is mostly a wrapper around the Linear library, which it also re-exports types, functions and operators from.

The most notable addition is Transform. A component that encodes the translation (position), rotation and scale of entities.

Transform is usually constructed with its Default instance, optionally specifying some of its fields:

insert (def {translation = V3 5 1 0})

To manipulate Transforms, you can import the following module:

import Mischief.Math.Transform qualified as Transform

This module contains a few useful functions, such as move which is used to update the translation:

Transform.move (V3 5 0 0) transform

Other notable functions are Transform.rotate. There is also Transform.rotateZ if you wish to rotate a 2d object.

Transform Propagation

You can add TransformPlugin to your app. This will propagate the transform of all entities through the ChildOf component. Basically, each entity's Transform will become their position relative to their parent.

This plugin also inserts the GlobalTransform component to all relevant entities, which is a wrapper around a Transform that's global.

module Linear

data Quat Source #

Instances

Instances details
Default Quat Source # 
Instance details

Defined in Mischief.Math.Quat

Methods

def :: Quat #

Num Quat Source # 
Instance details

Defined in Mischief.Math.Quat

Methods

(+) :: Quat -> Quat -> Quat #

(-) :: Quat -> Quat -> Quat #

(*) :: Quat -> Quat -> Quat #

negate :: Quat -> Quat #

abs :: Quat -> Quat #

signum :: Quat -> Quat #

fromInteger :: Integer -> Quat #

Show Quat Source # 
Instance details

Defined in Mischief.Math.Quat

Methods

showsPrec :: Int -> Quat -> ShowS #

show :: Quat -> String #

showList :: [Quat] -> ShowS #

Eq Quat Source # 
Instance details

Defined in Mischief.Math.Quat

Methods

(==) :: Quat -> Quat -> Bool #

(/=) :: Quat -> Quat -> Bool #

Ord Quat Source # 
Instance details

Defined in Mischief.Math.Quat

Methods

compare :: Quat -> Quat -> Ordering #

(<) :: Quat -> Quat -> Bool #

(<=) :: Quat -> Quat -> Bool #

(>) :: Quat -> Quat -> Bool #

(>=) :: Quat -> Quat -> Bool #

max :: Quat -> Quat -> Quat #

min :: Quat -> Quat -> Quat #

newtype GlobalTransform Source #

Constructors

GlobalTransform 

Fields

Instances

Instances details
Default GlobalTransform Source # 
Instance details

Defined in Mischief.Math.Transform

Generic GlobalTransform Source # 
Instance details

Defined in Mischief.Math.Transform

Associated Types

type Rep GlobalTransform 
Instance details

Defined in Mischief.Math.Transform

type Rep GlobalTransform = D1 ('MetaData "GlobalTransform" "Mischief.Math.Transform" "mischief-math-0.1.0.0-inplace" 'True) (C1 ('MetaCons "GlobalTransform" 'PrefixI 'True) (S1 ('MetaSel ('Just "transform") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Transform)))
Show GlobalTransform Source # 
Instance details

Defined in Mischief.Math.Transform

Component GlobalTransform Source # 
Instance details

Defined in Mischief.Math.Transform

Associated Types

type IsExclusiveRel GlobalTransform 
Instance details

Defined in Mischief.Math.Transform

type IsExclusiveRel GlobalTransform = 'False

Methods

required :: Set DefaultComponentType

onAdd :: [Hook GlobalTransform]

onSet :: [Hook GlobalTransform]

onRemove :: [Hook GlobalTransform]

onAddRel :: [HookRel GlobalTransform]

onSetRel :: [HookRel GlobalTransform]

onRemoveRel :: [HookRel GlobalTransform]

type Rep GlobalTransform Source # 
Instance details

Defined in Mischief.Math.Transform

type Rep GlobalTransform = D1 ('MetaData "GlobalTransform" "Mischief.Math.Transform" "mischief-math-0.1.0.0-inplace" 'True) (C1 ('MetaCons "GlobalTransform" 'PrefixI 'True) (S1 ('MetaSel ('Just "transform") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Transform)))
type IsExclusiveRel GlobalTransform Source # 
Instance details

Defined in Mischief.Math.Transform

type IsExclusiveRel GlobalTransform = 'False

data Transform Source #

Constructors

Transform 

Instances

Instances details
Default Transform Source # 
Instance details

Defined in Mischief.Math.Transform

Methods

def :: Transform #

Generic Transform Source # 
Instance details

Defined in Mischief.Math.Transform

Associated Types

type Rep Transform 
Instance details

Defined in Mischief.Math.Transform

type Rep Transform = D1 ('MetaData "Transform" "Mischief.Math.Transform" "mischief-math-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Transform" 'PrefixI 'True) (S1 ('MetaSel ('Just "translation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (V3 Float)) :*: (S1 ('MetaSel ('Just "rotation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Quat) :*: S1 ('MetaSel ('Just "scale") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (V3 Float)))))
Show Transform Source # 
Instance details

Defined in Mischief.Math.Transform

Eq Transform Source # 
Instance details

Defined in Mischief.Math.Transform

Component Transform Source # 
Instance details

Defined in Mischief.Math.Transform

Associated Types

type IsExclusiveRel Transform 
Instance details

Defined in Mischief.Math.Transform

type IsExclusiveRel Transform = 'False

Methods

required :: Set DefaultComponentType

onAdd :: [Hook Transform]

onSet :: [Hook Transform]

onRemove :: [Hook Transform]

onAddRel :: [HookRel Transform]

onSetRel :: [HookRel Transform]

onRemoveRel :: [HookRel Transform]

type Rep Transform Source # 
Instance details

Defined in Mischief.Math.Transform

type Rep Transform = D1 ('MetaData "Transform" "Mischief.Math.Transform" "mischief-math-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Transform" 'PrefixI 'True) (S1 ('MetaSel ('Just "translation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (V3 Float)) :*: (S1 ('MetaSel ('Just "rotation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Quat) :*: S1 ('MetaSel ('Just "scale") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (V3 Float)))))
type IsExclusiveRel Transform Source # 
Instance details

Defined in Mischief.Math.Transform

type IsExclusiveRel Transform = 'False

propTransform :: System () Source #

data TransformPlugin Source #

Instances

Instances details
Plugin TransformPlugin Source # 
Instance details

Defined in Mischief.Math.Transform.Plugin

Methods

deps :: [Dependency]

init :: System ()