# Math library

 File: Math.lib Version: 1.0 Author: Marcus Johansson

## Details

Some extra math functions.

## Constants

 Name Description M_PI# PI. M_D2R# For conversion from degrees to radians. M_R2D# For conversion from radians to degrees.

## Subroutines

### Conversion between number formats

Name
Parameters
Brief description
function
DecToBin\$
dec
Convert from decimal to binary.
function
BinToDec
bin\$
Convert from binary to decimal.
function
DecToHex\$
dec
function
HexToDec
hex\$

### Distances and angles

Name
Parameters
Brief description
function
Distance#
x1, y1, x2, y2
Returns distance between two integer points.
function
DistanceF#
x1#, y1#, x2#, y2#
Returns distance between two floating point points.
function
InvDistance#
x1, y1, x2, y2
Returns the inverted distance between two integer points.
function
InvDistanceF#
x1#, y1#, x2#, y2#
Returns the inverted distance between two floating point points.
function
AngleTo#
src_x, src_y, dst_x, dst_y
Angle from one integer point to another.
function
AngleToF#
src_x#, src_y#, dst_x#, dst_y#
Angle from one floating point point to another.

### 2D vectors

Name
Parameters
Brief description
procedure
&u#[], &v#[]
Add a vector 'v' to 'u'.
procedure
V_Sub
&u#[], &v#[]
Subtract vector 'v' from 'u'.
procedure
V_Scale
&u#[], s#
Multipy vector 'u' with scalar 's'.
procedure
V_Normalize
&u#[]
Normalize 'u'.
procedure
V_Rotate
&u#[], a#
procedure
V_Project
&u#[], &v#[]
Project vector 'u' on 'v'.
procedure
V_Reflect
&u#[], &v#[]
Reflect 'u' in 'v'.
function
&u#[], &v#[]
Get vector 'u + v'.
function
V_SubGet#[]
&u#[], &v#[]
Get vector 'u - v'.
function
V_ScaleGet#[]
&u#[], s#
Get vector 'u*s'.
function
V_NormalizeGet#[]
&u#[]
Get normalized vector 'u'.
function
V_RotateGet#[]
&u#[], a#
function
V_ProjectGet#[]
&u#[], &v#[]
Get vector 'u' projected on 'v'.
function
V_ReflectGet#[]
&u#[], &v#[]
Get vector 'u' reflected in 'v'.
function
V_Size#
&u#[]
Get size of 'u'.
function
V_Dot#
&u#[], &v#[]
Get vector dot product 'u*v'.
function
V_Cross#
&u#[], &v#[]
Get determinant 'u x v'.
function
V_Angle#
&u#[]
Get angle of vector 'u'.
function
V_AngleBetween#
&u#[], &v#[]
Get angle between vector 'u' and 'v'.
function
V_Equal
&u#[], &v#[]
Return true if 'u' and 'v' are equal.
function
V_Parallel
&u#[], &v#[]
Return true if 'u' and 'v' are parallel.

## Subroutine documentation

### function DecToBin\$ ( dec )

Convert from decimal to binary.

 Parameter Mode Description dec In Decimal value.

Return value
Binary value as a string.

[ Back ]

### function BinToDec ( bin\$ )

Convert from binary to decimal.

 Parameter Mode Description bin In Binary value.

Return value
Decimal value.

[ Back ]

### function DecToHex\$ ( dec )

 Parameter Mode Description dec In Decimal value.

Return value

[ Back ]

### function HexToDec ( hex\$ )

 Parameter Mode Description hex In Hexadecimal value.

Return value
Decimal value.

[ Back ]

### function Distance# ( x1, y1, x2, y2 )

Returns distance between two integer points.

 Parameter Mode Description x1 In X-coordinate of first point. y1 In Y-coordinate of first point. x2 In X-coordinate of second point. y2 In Y-coordinate of second point.

Return value
Distance between the two points.

[ Back ]

### function DistanceF# ( x1#, y1#, x2#, y2# )

Returns distance between two floating point points.

 Parameter Mode Description x1 In X-coordinate of first point. y1 In Y-coordinate of first point. x2 In X-coordinate of second point. y2 In Y-coordinate of second point.

Return value
Distance between the two points.

[ Back ]

### function InvDistance# ( x1, y1, x2, y2 )

Returns the inverted distance between two integer points.

 Parameter Mode Description x1 In X-coordinate of first point. y1 In Y-coordinate of first point. x2 In X-coordinate of second point. y2 In Y-coordinate of second point.

Return value
Distance between the two points.

[ Back ]

### function InvDistanceF# ( x1#, y1#, x2#, y2# )

Returns the inverted distance between two floating point points.

 Parameter Mode Description x1 In X-coordinate of first point. y1 In Y-coordinate of first point. x2 In X-coordinate of second point. y2 In Y-coordinate of second point.

Return value
Distance between the two points.

[ Back ]

### function AngleTo# ( src_x, src_y, dst_x, dst_y )

Angle from one integer point to another.

 Parameter Mode Description src_x In X-coordinate of first point. src_y In Y-coordinate of first point. dst_x In X-coordinate of second point. dst_y In Y-coordinate of second point.

Return value
The angle.

[ Back ]

### function AngleToF# ( src_x#, src_y#, dst_x#, dst_y# )

Angle from one floating point point to another.

 Parameter Mode Description src_x In X-coordinate of first point. src_y In Y-coordinate of first point. dst_x In X-coordinate of second point. dst_y In Y-coordinate of second point.

Return value
The angle.

[ Back ]

### procedure V_Add ( &u#[], &v#[] )

Add a vector 'v' to 'u'.

 Parameter Mode Description u In Resulting vector. v In Vector.

[ Back ]

### procedure V_Sub ( &u#[], &v#[] )

Subtract vector 'v' from 'u'.

 Parameter Mode Description u In Resulting vector. v In Vector.

[ Back ]

### procedure V_Scale ( &u#[], s# )

Multipy vector 'u' with scalar 's'.

 Parameter Mode Description u In Resulting vector. s In Scalar.

[ Back ]

### procedure V_Normalize ( &u#[] )

Normalize 'u'.

 Parameter Mode Description u In Resulting vector.

[ Back ]

### procedure V_Rotate ( &u#[], a# )

 Parameter Mode Description u In Resulting vector. a In Angle.

[ Back ]

### procedure V_Project ( &u#[], &v#[] )

Project vector 'u' on 'v'.

 Parameter Mode Description u In Resulting vector. v In Vector.

[ Back ]

### procedure V_Reflect ( &u#[], &v#[] )

Reflect 'u' in 'v'.

 Parameter Mode Description u In Resulting vector. v In Vector.

[ Back ]

### function V_AddGet#[] ( &u#[], &v#[] )

Get vector 'u + v'.

 Parameter Mode Description u In Vector. v In Vector.

Return value
Vector 'u + v'.

[ Back ]

### function V_SubGet#[] ( &u#[], &v#[] )

Get vector 'u - v'.

 Parameter Mode Description u In Vector. v In Vector.

Return value
Vector 'u - v'.

[ Back ]

### function V_ScaleGet#[] ( &u#[], s# )

Get vector 'u*s'.

 Parameter Mode Description u In Vector. s In Scalar.

Return value
'u*s'.

[ Back ]

### function V_NormalizeGet#[] ( &u#[] )

Get normalized vector 'u'.

 Parameter Mode Description u In Vector. Normalized In vector 'u'.

Return value

[ Back ]

### function V_RotateGet#[] ( &u#[], a# )

 Parameter Mode Description u In Vector. a In Angle.

Return value

[ Back ]

### function V_ProjectGet#[] ( &u#[], &v#[] )

Get vector 'u' projected on 'v'.

 Parameter Mode Description u In Vector. v In Vector.

Return value
Vector 'u' projected on 'v'.

[ Back ]

### function V_ReflectGet#[] ( &u#[], &v#[] )

Get vector 'u' reflected in 'v'.

 Parameter Mode Description u In Vector. v In Vector.

Return value
Vector 'u' reflected in 'v'.

[ Back ]

### function V_Size# ( &u#[] )

Get size of 'u'.

 Parameter Mode Description u In Vector.

Return value
Size of 'u'.

[ Back ]

### function V_Dot# ( &u#[], &v#[] )

Get vector dot product 'u*v'.

 Parameter Mode Description u In Vector. v In Vector.

Return value
Dot product 'u*v'.

[ Back ]

### function V_Cross# ( &u#[], &v#[] )

Get determinant 'u x v'.

 Parameter Mode Description u In Vector. v In Vector.

Return value
Determinant.

[ Back ]

### function V_Angle# ( &u#[] )

Get angle of vector 'u'.

 Parameter Mode Description u In Vector.

Return value
Angle.

[ Back ]

### function V_AngleBetween# ( &u#[], &v#[] )

Get angle between vector 'u' and 'v'.

 Parameter Mode Description u In Vector. v In Vector.

Return value
Angle.

[ Back ]

### function V_Equal ( &u#[], &v#[] )

Return true if 'u' and 'v' are equal.

 Parameter Mode Description u In Vector. v In Vector.

Return value
True if equal.

[ Back ]

### function V_Parallel ( &u#[], &v#[] )

Return true if 'u' and 'v' are parallel.

 Parameter Mode Description u In Vector. v In Vector.

Return value
True if parallel.

[ Back ]

Generated with NLDoc 20140626.