Box2D
Safe HaskellNone
LanguageGHC2021

Box2D.MathTypes

Contents

Description

Low-level bindings to the value types in box2d/math_functions.h.

These are the small POD math structs that the Box2D API passes and returns by value. Field order matches the C layout; Storable offsets come straight from the header via hsc2hs. Fields are Float because C float maps to the Haskell FFI Float with an identical representation.

In single-precision builds (the default) b2Pos and b2WorldTransform are typedefs for b2Vec2 and b2Transform, so Pos and WorldTransform are type synonyms here.

Synopsis

Documentation

data Vec2 Source #

A 2D vector.

Constructors

Vec2 Float Float 

Instances

Instances details
Storable Vec2 Source # 
Instance details

Defined in Box2D.MathTypes

Methods

sizeOf :: Vec2 -> Int #

alignment :: Vec2 -> Int #

peekElemOff :: Ptr Vec2 -> Int -> IO Vec2 #

pokeElemOff :: Ptr Vec2 -> Int -> Vec2 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Vec2 #

pokeByteOff :: Ptr b -> Int -> Vec2 -> IO () #

peek :: Ptr Vec2 -> IO Vec2 #

poke :: Ptr Vec2 -> Vec2 -> IO () #

Show Vec2 Source # 
Instance details

Defined in Box2D.MathTypes

Methods

showsPrec :: Int -> Vec2 -> ShowS #

show :: Vec2 -> String #

showList :: [Vec2] -> ShowS #

Eq Vec2 Source # 
Instance details

Defined in Box2D.MathTypes

Methods

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

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

data CosSin Source #

Cosine and sine pair (cosine, sine).

Constructors

CosSin Float Float 

Instances

Instances details
Storable CosSin Source # 
Instance details

Defined in Box2D.MathTypes

Show CosSin Source # 
Instance details

Defined in Box2D.MathTypes

Eq CosSin Source # 
Instance details

Defined in Box2D.MathTypes

Methods

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

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

data Rot Source #

A 2D rotation stored as a cosine/sine pair (c, s).

Constructors

Rot Float Float 

Instances

Instances details
Storable Rot Source # 
Instance details

Defined in Box2D.MathTypes

Methods

sizeOf :: Rot -> Int #

alignment :: Rot -> Int #

peekElemOff :: Ptr Rot -> Int -> IO Rot #

pokeElemOff :: Ptr Rot -> Int -> Rot -> IO () #

peekByteOff :: Ptr b -> Int -> IO Rot #

pokeByteOff :: Ptr b -> Int -> Rot -> IO () #

peek :: Ptr Rot -> IO Rot #

poke :: Ptr Rot -> Rot -> IO () #

Show Rot Source # 
Instance details

Defined in Box2D.MathTypes

Methods

showsPrec :: Int -> Rot -> ShowS #

show :: Rot -> String #

showList :: [Rot] -> ShowS #

Eq Rot Source # 
Instance details

Defined in Box2D.MathTypes

Methods

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

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

data Transform Source #

A 2D rigid transform: position p and rotation q.

Constructors

Transform Vec2 Rot 

Instances

Instances details
Storable Transform Source # 
Instance details

Defined in Box2D.MathTypes

Show Transform Source # 
Instance details

Defined in Box2D.MathTypes

Eq Transform Source # 
Instance details

Defined in Box2D.MathTypes

data Mat22 Source #

A 2x2 column-major matrix (columns cx, cy).

Constructors

Mat22 Vec2 Vec2 

Instances

Instances details
Storable Mat22 Source # 
Instance details

Defined in Box2D.MathTypes

Methods

sizeOf :: Mat22 -> Int #

alignment :: Mat22 -> Int #

peekElemOff :: Ptr Mat22 -> Int -> IO Mat22 #

pokeElemOff :: Ptr Mat22 -> Int -> Mat22 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Mat22 #

pokeByteOff :: Ptr b -> Int -> Mat22 -> IO () #

peek :: Ptr Mat22 -> IO Mat22 #

poke :: Ptr Mat22 -> Mat22 -> IO () #

Show Mat22 Source # 
Instance details

Defined in Box2D.MathTypes

Methods

showsPrec :: Int -> Mat22 -> ShowS #

show :: Mat22 -> String #

showList :: [Mat22] -> ShowS #

Eq Mat22 Source # 
Instance details

Defined in Box2D.MathTypes

Methods

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

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

data AABB Source #

Axis-aligned bounding box (lowerBound, upperBound).

Constructors

AABB Vec2 Vec2 

Instances

Instances details
Storable AABB Source # 
Instance details

Defined in Box2D.MathTypes

Methods

sizeOf :: AABB -> Int #

alignment :: AABB -> Int #

peekElemOff :: Ptr AABB -> Int -> IO AABB #

pokeElemOff :: Ptr AABB -> Int -> AABB -> IO () #

peekByteOff :: Ptr b -> Int -> IO AABB #

pokeByteOff :: Ptr b -> Int -> AABB -> IO () #

peek :: Ptr AABB -> IO AABB #

poke :: Ptr AABB -> AABB -> IO () #

Show AABB Source # 
Instance details

Defined in Box2D.MathTypes

Methods

showsPrec :: Int -> AABB -> ShowS #

show :: AABB -> String #

showList :: [AABB] -> ShowS #

Eq AABB Source # 
Instance details

Defined in Box2D.MathTypes

Methods

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

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

data Plane Source #

A plane: normal and offset where separation = dot(normal, point) - offset.

Constructors

Plane Vec2 Float 

Instances

Instances details
Storable Plane Source # 
Instance details

Defined in Box2D.MathTypes

Methods

sizeOf :: Plane -> Int #

alignment :: Plane -> Int #

peekElemOff :: Ptr Plane -> Int -> IO Plane #

pokeElemOff :: Ptr Plane -> Int -> Plane -> IO () #

peekByteOff :: Ptr b -> Int -> IO Plane #

pokeByteOff :: Ptr b -> Int -> Plane -> IO () #

peek :: Ptr Plane -> IO Plane #

poke :: Ptr Plane -> Plane -> IO () #

Show Plane Source # 
Instance details

Defined in Box2D.MathTypes

Methods

showsPrec :: Int -> Plane -> ShowS #

show :: Plane -> String #

showList :: [Plane] -> ShowS #

Eq Plane Source # 
Instance details

Defined in Box2D.MathTypes

Methods

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

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

type Pos = Vec2 Source #

World position. In single-precision builds this is Vec2.

type WorldTransform = Transform Source #

World transform. In single-precision builds this is Transform.

Constants

rotIdentity :: Rot Source #

The identity rotation (cosine 1, sine 0).