Library "Vector2Operations"
functions to handle vector2 operations.
math_fractional(_value) computes the fractional part of the argument value.
Parameters:
atan2(_a) Approximation to atan2 calculation, arc tangent of y/ x in the range radians.
Parameters:
set_x(_a, _value) Set the x value of vector _a.
Parameters:
set_y(_a, _value) Set the y value of vector _a.
Parameters:
get_x(_a) Get the x value of vector _a.
Parameters:
get_y(_a) Get the y value of vector _a.
Parameters:
get_xy(_a) Return the tuple of vector _a in the form
Parameters:
length_squared(_a) Length of vector _a in the form. , for comparing vectors this is computationaly lighter.
Parameters:
length(_a) Magnitude of vector _a in the form.
Parameters:
vmin(_a) Lowest element of vector.
Parameters:
vmax(_a) Highest element of vector.
Parameters:
from(_value) Assigns value to a new vector x,y elements.
Parameters:
new(_x, _y) Creates a prototype array to handle vectors.
Parameters:
down() Vector in the form . Returns: float vector.
left() Vector in the form . Returns: float vector.
one() Vector in the form . Returns: float vector.
right() Vector in the form . Returns: float vector
up() Vector in the form . Returns: float vector
zero() Vector in the form . Returns: float vector
add(_a, _b) Adds vector _b to _a, in the form
.
Parameters:
subtract(_a, _b) Subtract vector _b from _a, in the form
.
Parameters:
multiply(_a, _b) Multiply vector _a with _b, in the form
Parameters:
divide(_a, _b) Divide vector _a with _b, in the form
Parameters:
negate(_a) Negative of vector _a, in the form
Parameters:
perp(_a) Perpendicular Vector of _a.
Parameters:
vfloor(_a) Compute the floor of argument vector _a.
Parameters:
fractional(_a) Compute the fractional part of the elements from vector _a.
Parameters:
vsin(_a) Compute the sine of argument vector _a.
Parameters:
equals(_a, _b) Compares two vectors
Parameters:
dot(_a, _b) Dot product of 2 vectors, in the form
Parameters:
cross_product(_a, _b) cross product of 2 vectors, in the form
Parameters:
scale(_a, _scalar) Multiply a vector by a scalar.
Parameters:
normalize(_a) Vector _a normalized with a magnitude of 1, in the form.
Parameters:
rescale(_a) Rescale a vector to a new Magnitude.
Parameters:
rotate(_a, _radians) Rotates vector _a by angle value
Parameters:
rotate_degree(_a, _degree) Rotates vector _a by angle value
Parameters:
rotate_around(_center, _target, _degree) Rotates vector _target around _origin by angle value
Parameters:
vceil(_a, _digits) Ceils vector _a
Parameters:
vpow(_a) Raise both vector elements by a exponent.
Parameters:
distance(_a, _b) vector distance between 2 vectors.
Parameters:
project(_a, _axis) Project a vector onto another.
Parameters:
projectN(_a, _axis) Project a vector onto a vector of unit length.
Parameters:
reflect(_a, _b) Reflect a vector on another.
Parameters:
reflectN(_a, _b) Reflect a vector to a arbitrary axis.
Parameters:
angle(_a) Angle in radians of a vector.
Parameters:
angle_unsigned(_a, _b) unsigned degree angle between 0 and +180 by given two vectors.
Parameters:
angle_signed(_a, _b) Signed degree angle between -180 and +180 by given two vectors.
Parameters:
angle_360(_a, _b) Degree angle between 0 and 360 by given two vectors
Parameters:
clamp(_a, _vmin, _vmax) Restricts a vector between a min and max value.
Parameters:
lerp(_a, _b, _rate_of_move) Linearly interpolates between vectors a and b by _rate_of_move.
Parameters:
herp(_a, _b, _rate_of_move) Hermite curve interpolation between vectors a and b by _rate_of_move.
Parameters:
area_triangle(_a, _b, _c) Find the area in a triangle of vectors.
Parameters:
to_string(_a) Converts vector _a to a string format, in the form "(x, y)"
Parameters:
vrandom(_max) 2D random value
Parameters:
noise(_a) 2D Noise based on Morgan McGuire @morgan3d
thebookofshaders.com/11/
www.shadertoy.com/view/4dS3Wd
Parameters:
array_new(_size, _initial_vector) Prototype to initialize a array of vectors.
Parameters:
array_size(_id) number of vector elements in array.
Parameters:
array_get(_id, _index) Get the vector in a array, in the form of a array
Parameters:
array_set(_id, _index, _a) Sets the values vector in a array.
Parameters:
array_push(_id, _a) inserts the vector at the end of array.
Parameters:
array_unshift(_id, _a) inserts the vector at the begining of array.
Parameters:
array_pop(_id, _a) removes the last vector of array and returns it.
Parameters:
array_shift(_id, _a) removes the first vector of array and returns it.
Parameters:
array_sum(_id) Total sum of all vectors.
Parameters:
array_center(_id) Finds the vector center of the array.
Parameters:
array_rotate_points(_id) Rotate Array vectors around origin vector by a angle.
Parameters:
array_scale_points(_id) Scale Array vectors based on a origin vector perspective.
Parameters:
array_tostring(_id, _separator) Reads a array of vectors into a string, of the form """
Parameters:
line_new(_a, _b) 2 vector line in the form.
Parameters:
line_get_a(_line) Start vector of a line.
Parameters:
line_get_b(_line) End vector of a line.
Parameters:
line_intersect(_line1, _line2) Find the intersection vector of 2 lines.
Parameters:
draw_line(_line, _xloc, _extend, _color, _style, _width) Draws a line using line prototype.
Parameters:
draw_triangle(_v1, _v2, _v3, _xloc, _color, _style, _width) Draws a triangle using line prototype.
Parameters:
draw_rect(_v1, _size, _angle, _xloc, _color, _style, _width) Draws a square using vector2 line prototype.
Parameters:
functions to handle vector2 operations.
math_fractional(_value) computes the fractional part of the argument value.
Parameters:
- _value: float, value to compute.
atan2(_a) Approximation to atan2 calculation, arc tangent of y/ x in the range radians.
Parameters:
- _a: vector2 in the form of a array .
set_x(_a, _value) Set the x value of vector _a.
Parameters:
- _a: vector2 in the form of a array .
- _value: value to replace x value of _a.
set_y(_a, _value) Set the y value of vector _a.
Parameters:
- _a: vector in the form of a array .
- _value: value to replace y value of _a.
get_x(_a) Get the x value of vector _a.
Parameters:
- _a: vector in the form of a array .
get_y(_a) Get the y value of vector _a.
Parameters:
- _a: vector in the form of a array .
get_xy(_a) Return the tuple of vector _a in the form
Parameters:
- _a: vector2 in the form of a array .
length_squared(_a) Length of vector _a in the form. , for comparing vectors this is computationaly lighter.
Parameters:
- _a: vector in the form of a array .
length(_a) Magnitude of vector _a in the form.
Parameters:
- _a: vector in the form of a array .
vmin(_a) Lowest element of vector.
Parameters:
- _a: vector in the form of a array .
vmax(_a) Highest element of vector.
Parameters:
- _a: vector in the form of a array .
from(_value) Assigns value to a new vector x,y elements.
Parameters:
- _value: x and y value of the vector. optional.
new(_x, _y) Creates a prototype array to handle vectors.
Parameters:
- _x: float, x value of the vector. optional.
- _y: float, y number of the vector. optional.
down() Vector in the form . Returns: float vector.
left() Vector in the form . Returns: float vector.
one() Vector in the form . Returns: float vector.
right() Vector in the form . Returns: float vector
up() Vector in the form . Returns: float vector
zero() Vector in the form . Returns: float vector
add(_a, _b) Adds vector _b to _a, in the form
.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
subtract(_a, _b) Subtract vector _b from _a, in the form
.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
multiply(_a, _b) Multiply vector _a with _b, in the form
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
divide(_a, _b) Divide vector _a with _b, in the form
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
negate(_a) Negative of vector _a, in the form
Parameters:
- _a: vector in the form of a array .
perp(_a) Perpendicular Vector of _a.
Parameters:
- _a: vector in the form of a array .
vfloor(_a) Compute the floor of argument vector _a.
Parameters:
- _a: vector in the form of a array .
fractional(_a) Compute the fractional part of the elements from vector _a.
Parameters:
- _a: vector in the form of a array .
vsin(_a) Compute the sine of argument vector _a.
Parameters:
- _a: vector in the form of a array .
equals(_a, _b) Compares two vectors
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
dot(_a, _b) Dot product of 2 vectors, in the form
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
cross_product(_a, _b) cross product of 2 vectors, in the form
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
scale(_a, _scalar) Multiply a vector by a scalar.
Parameters:
- _a: vector in the form of a array .
- _scalar: value to multiply vector elements by.
normalize(_a) Vector _a normalized with a magnitude of 1, in the form.
Parameters:
- _a: vector in the form of a array .
rescale(_a) Rescale a vector to a new Magnitude.
Parameters:
- _a: vector in the form of a array .
rotate(_a, _radians) Rotates vector _a by angle value
Parameters:
- _a: vector in the form of a array .
- _radians: Angle value.
rotate_degree(_a, _degree) Rotates vector _a by angle value
Parameters:
- _a: vector in the form of a array .
- _degree: Angle value.
rotate_around(_center, _target, _degree) Rotates vector _target around _origin by angle value
Parameters:
- _center: vector in the form of a array .
- _target: vector in the form of a array .
- _degree: Angle value.
vceil(_a, _digits) Ceils vector _a
Parameters:
- _a: vector in the form of a array .
- _digits: digits to use as ceiling.
vpow(_a) Raise both vector elements by a exponent.
Parameters:
- _a: vector in the form of a array .
distance(_a, _b) vector distance between 2 vectors.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
project(_a, _axis) Project a vector onto another.
Parameters:
- _a: vector in the form of a array .
- _axis: float vector2
projectN(_a, _axis) Project a vector onto a vector of unit length.
Parameters:
- _a: vector in the form of a array .
- _axis: vector in the form of a array .
reflect(_a, _b) Reflect a vector on another.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
reflectN(_a, _b) Reflect a vector to a arbitrary axis.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
angle(_a) Angle in radians of a vector.
Parameters:
- _a: vector in the form of a array .
angle_unsigned(_a, _b) unsigned degree angle between 0 and +180 by given two vectors.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
angle_signed(_a, _b) Signed degree angle between -180 and +180 by given two vectors.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
angle_360(_a, _b) Degree angle between 0 and 360 by given two vectors
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
clamp(_a, _vmin, _vmax) Restricts a vector between a min and max value.
Parameters:
- _a: vector in the form of a array .
- _vmin: vector in the form of a array .
- _vmax: vector in the form of a array .
lerp(_a, _b, _rate_of_move) Linearly interpolates between vectors a and b by _rate_of_move.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
- _rate_of_move: float value between (a:-infinity -> b:1.0), negative values will move away from b.
herp(_a, _b, _rate_of_move) Hermite curve interpolation between vectors a and b by _rate_of_move.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
- _rate_of_move: float value between (a-infinity -> b1.0), negative values will move away from b.
area_triangle(_a, _b, _c) Find the area in a triangle of vectors.
Parameters:
- _a: vector in the form of a array .
- _b: vector in the form of a array .
- _c: vector in the form of a array .
to_string(_a) Converts vector _a to a string format, in the form "(x, y)"
Parameters:
- _a: vector in the form of a array .
vrandom(_max) 2D random value
Parameters:
- _max: float vector, vector upper bound
noise(_a) 2D Noise based on Morgan McGuire @morgan3d
thebookofshaders.com/11/
www.shadertoy.com/view/4dS3Wd
Parameters:
- _a: vector in the form of a array .
array_new(_size, _initial_vector) Prototype to initialize a array of vectors.
Parameters:
- _size: size of the array.
- _initial_vector: vector to be used as default value, in the form of array .
array_size(_id) number of vector elements in array.
Parameters:
- _id: ID of the array.
array_get(_id, _index) Get the vector in a array, in the form of a array
Parameters:
- _id: ID of the array.
- _index: Index of the vector.
array_set(_id, _index, _a) Sets the values vector in a array.
Parameters:
- _id: ID of the array.
- _index: Index of the vector.
- _a: vector, in the form .
array_push(_id, _a) inserts the vector at the end of array.
Parameters:
- _id: ID of the array.
- _a: vector, in the form .
array_unshift(_id, _a) inserts the vector at the begining of array.
Parameters:
- _id: ID of the array.
- _a: vector, in the form .
array_pop(_id, _a) removes the last vector of array and returns it.
Parameters:
- _id: ID of the array.
- _a: vector, in the form .
array_shift(_id, _a) removes the first vector of array and returns it.
Parameters:
- _id: ID of the array.
- _a: vector, in the form .
array_sum(_id) Total sum of all vectors.
Parameters:
- _id: ID of the array.
array_center(_id) Finds the vector center of the array.
Parameters:
- _id: ID of the array.
array_rotate_points(_id) Rotate Array vectors around origin vector by a angle.
Parameters:
- _id: ID of the array.
array_scale_points(_id) Scale Array vectors based on a origin vector perspective.
Parameters:
- _id: ID of the array.
array_tostring(_id, _separator) Reads a array of vectors into a string, of the form """
Parameters:
- _id: ID of the array.
- _separator: string separator for cell splitting.
line_new(_a, _b) 2 vector line in the form.
Parameters:
- _a: vector, in the form .
- _b: vector, in the form .
line_get_a(_line) Start vector of a line.
Parameters:
- _line: vector4, in the form .
line_get_b(_line) End vector of a line.
Parameters:
- _line: vector4, in the form .
line_intersect(_line1, _line2) Find the intersection vector of 2 lines.
Parameters:
- _line1: line of 2 vectors in the form of a array .
- _line2: line of 2 vectors in the form of a array .
draw_line(_line, _xloc, _extend, _color, _style, _width) Draws a line using line prototype.
Parameters:
- _line: vector4, in the form .
- _xloc: string
- _extend: string
- _color: color
- _style: string
- _width: int
draw_triangle(_v1, _v2, _v3, _xloc, _color, _style, _width) Draws a triangle using line prototype.
Parameters:
- _v1: vector4, in the form .
- _v2: vector4, in the form .
- _v3: vector4, in the form .
- _xloc: string
- _color: color
- _style: string
- _width: int
draw_rect(_v1, _size, _angle, _xloc, _color, _style, _width) Draws a square using vector2 line prototype.
Parameters:
- _v1: vector4, in the form .
- _size: float
- _angle: float
- _xloc: string
- _color: color
- _style: string
- _width: int
リリースノート:
v2 changed label to console for displaying examples.
Added:
perpendicular_distance(_a, _b, _c) Distance from point _a to line between _b and _c.
Parameters:
_a: vector in the form of a array .
_b: vector in the form of a array .
_c: vector in the form of a array .
Returns: float
Added:
perpendicular_distance(_a, _b, _c) Distance from point _a to line between _b and _c.
Parameters:
_a: vector in the form of a array .
_b: vector in the form of a array .
_c: vector in the form of a array .
Returns: float