Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
A structure capable of holding a vector with two dimensions, x and y.
The contents of the Vec2
structure are private and should
never be accessed directly.
Synopsis
- newtype Vec2 = Vec2 (ManagedPtr Vec2)
- newZeroVec2 :: MonadIO m => m Vec2
- noVec2 :: Maybe Vec2
- vec2Add :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Vec2
- vec2Alloc :: (HasCallStack, MonadIO m) => m Vec2
- vec2Divide :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Vec2
- vec2Dot :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Float
- vec2Equal :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Bool
- vec2Free :: (HasCallStack, MonadIO m) => Vec2 -> m ()
- vec2GetX :: (HasCallStack, MonadIO m) => Vec2 -> m Float
- vec2GetY :: (HasCallStack, MonadIO m) => Vec2 -> m Float
- vec2Init :: (HasCallStack, MonadIO m) => Vec2 -> Float -> Float -> m Vec2
- vec2InitFromFloat :: (HasCallStack, MonadIO m) => Vec2 -> [Float] -> m Vec2
- vec2InitFromVec2 :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Vec2
- vec2Length :: (HasCallStack, MonadIO m) => Vec2 -> m Float
- vec2Max :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Vec2
- vec2Min :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Vec2
- vec2Multiply :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Vec2
- vec2Near :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> Float -> m Bool
- vec2Negate :: (HasCallStack, MonadIO m) => Vec2 -> m Vec2
- vec2Normalize :: (HasCallStack, MonadIO m) => Vec2 -> m Vec2
- vec2One :: (HasCallStack, MonadIO m) => m Vec2
- vec2Scale :: (HasCallStack, MonadIO m) => Vec2 -> Float -> m Vec2
- vec2Subtract :: (HasCallStack, MonadIO m) => Vec2 -> Vec2 -> m Vec2
- vec2XAxis :: (HasCallStack, MonadIO m) => m Vec2
- vec2YAxis :: (HasCallStack, MonadIO m) => m Vec2
- vec2Zero :: (HasCallStack, MonadIO m) => m Vec2
Exported types
Memory-managed wrapper type.
Methods
Overloaded methods
add
Adds each component of the two passed vectors and places
each result into the components of res
.
Since: 1.0
alloc
:: (HasCallStack, MonadIO m) | |
=> m Vec2 | Returns: the newly allocated |
divide
Divides each component of the first operand a
by the corresponding
component of the second operand b
, and places the results into the
vector res
.
Since: 1.0
dot
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> Vec2 |
|
-> m Float | Returns: the dot product of the vectors |
Computes the dot product of the two given vectors.
Since: 1.0
equal
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> Vec2 |
|
-> m Bool | Returns: |
Checks whether the two given Vec2
are equal.
Since: 1.2
free
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> m () |
Frees the resources allocated by v
Since: 1.0
getX
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> m Float | Returns: the value of the X component |
Retrieves the X component of the Vec2
.
Since: 1.0
getY
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> m Float | Returns: the value of the Y component |
Retrieves the Y component of the Vec2
.
Since: 1.0
init
initFromFloat
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> [Float] |
|
-> m Vec2 | Returns: the initialized vector |
Initializes v
with the contents of the given array.
Since: 1.0
initFromVec2
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> Vec2 |
|
-> m Vec2 | Returns: the initialized vector |
Copies the contents of src
into v
.
Since: 1.0
length
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> m Float | Returns: the length of the vector |
Computes the length of the given vector.
Since: 1.0
max
Compares the two given vectors and places the maximum
values of each component into res
.
Since: 1.0
min
Compares the two given vectors and places the minimum
values of each component into res
.
Since: 1.0
multiply
Multiplies each component of the two passed vectors and places
each result into the components of res
.
Since: 1.0
near
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> Vec2 |
|
-> Float |
|
-> m Bool | Returns: |
Compares the two given Vec2
vectors and checks
whether their values are within the given epsilon
.
Since: 1.2
negate
normalize
:: (HasCallStack, MonadIO m) | |
=> Vec2 |
|
-> m Vec2 |
Computes the normalized vector for the given vector v
.
Since: 1.0
one
:: (HasCallStack, MonadIO m) | |
=> m Vec2 | Returns: the one vector |
Retrieves a constant vector with (1, 1) components.
Since: 1.0
scale
Multiplies all components of the given vector with the given scalar factor
.
Since: 1.2
subtract
Subtracts from each component of the first operand a
the
corresponding component of the second operand b
and places
each result into the components of res
.
Since: 1.0
xAxis
:: (HasCallStack, MonadIO m) | |
=> m Vec2 | Returns: the X axis vector |
Retrieves a constant vector with (1, 0) components.
Since: 1.0
yAxis
:: (HasCallStack, MonadIO m) | |
=> m Vec2 | Returns: the Y axis vector |
Retrieves a constant vector with (0, 1) components.
Since: 1.0