Package rope.vector
Class vec2
java.lang.Object
rope.vector.vec
rope.vector.vec2
- All Implemented Interfaces:
R_Constants
-
Field Summary
Fields inherited from interface rope.core.R_Constants
ARC, BEZIER_VERTEX, BLANK, BOTTOM, BOX, BREAK, CARTESIAN, CENTER, CHAOS, CHOICE, CHORD, CIRCULAR, CLOSE, CLOUD, CORNER, CORNERS, COS, CROSS, CROSS_BOX_2, CROSS_BOX_3, CROSS_RECT, CUBE_LINE, CURVE_VERTEX, DECAGON, DIAGONAL, DIAMETER, DODECAGON, DOWN, DRAW, DXF, DYNAMIC, EAST, ELLIPSE, EQUATION, EULER, FIRST, FIT, FLOWER, FLUID, FX2D, G, GOLD_ANGLE, GOLD_NUMBER, GRAVITY, HALF, HALF_PI, HENDECAGON, HEPTAGON, HEXAGON, HORIZONTAL, HOUSE, HPI, ICOSI_DODECAHEDRON_LINE, IMAGE, JAVA2D, LANDSCAPE, LAST, LEAF, LEFT, LINE, LINEAR, MAD, MAGNETIC, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MIX, NEXT, NONAGON, NONE, NORMAL, NORTH, NORTH_EAST, NORTH_WEST, NOTCH, NOTHING, NULL, OCTOGON, OCTOHEDRON_LINE, OPEN, ORDER, P2D, P3D, PDF, PENTAGON, PERLIN, PHI, PI, PIE, PIXEL, POINT, POLAR, POLYGON, PORTRAIT, POW, PREVIOUS, QPI, QUADRATIC_VERTEX, QUARTER_PI, RADIUS, RAND, RECT, REPEAT, RHOMBIC_COSI_DODECAHEDRON_SMALL_LINE, RIGHT, ROOT, ROOT2, RUN, SCALE, SEED, SHAPE, SIN, SKY, SOUTH, SOUTH_EAST, SOUTH_WEST, SPAN, SPHERE, SPHERE_HIGH, SPHERE_LOW, SPHERE_MEDIUM, SPIRAL, SQUARE, STAR, STAR_3D, STATIC, SVG, TAN, TAU, TETRAHEDRON, TETRAHEDRON_LINE, TEXT, TOP, TREE, TRIANGLE, TWO_PI, UP, VERSION, VERTEX, VERTICAL, VIRUS, WALK, WEST
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(float a) add
(float ax, float ay) add float valueadd_x
(float x) add_y
(float y) float
angle()
Calculate the angle of rotation for this vector (only 2D vectors)float
return heading anglefloat
average()
average of all componentsbboolean
return true if the vector this and vector target are in the same vector areaconstrain
(float max) constrain
(float min, float max) Constrains a value to not exceed a maximum and minimum value.copy()
copy() return all the component of veccos_wave
(int timeline, float s) cos_wave
(int timeline, float sx, float sy) dir()
return normal cartesian angle coorddir
(float a_x, float a_y) return normal cartesian angle coordreturn normal cartesian angle coordfloat
return distance of the vector or lengthdiv
(float d) div
(float dx, float dy) divide Vector by a float valuediv_x
(float x) div_y
(float y) float
dot
(float x, float y) float
boolean
equals
(float target) return true if the vector this is equals to float targetboolean
equals
(float t_x, float t_y) * return true if the vector this is equals to float argumentsboolean
return true if the vector this is equals to vector targetfloat
heading()
Calculate the angle of rotation for this vector (only 2D vectors)boolean
https://forum.processing.org/two/discussion/90/point-and-line-intersection-detection refactoring from Quark Algorithmboolean
in_polygon
(vec[] points) https://forum.processing.org/one/topic/how-do-i-find-if-a-point-is-inside-a-complex-polygon.html http://paulbourke.net/geometry/ thks to Moggach and Paul Brookinv()
jitter
(int range) JITTERjitter
(int range_x, int range_y) limit
(float max) float
mag()
return square root of magnitude or length of vec2float
return mag between this vector and the targetfloat
magSq()
return square of vecmap
(float minIn, float maxIn, float minOut, float maxOut) mod
(float mod) mod
(float mod_x, float mod_y) mult
(float m) mult
(float mx, float my) multiply Vector by different float valuemult_x
(float x) mult_y
(float y) Normalize vectorpow
(float pow) pow
(float pow_x, float pow_y) return the power result of this vectorrand
(float max) randomrand
(float min, float max) randomrandoms
(float x) set
(float v) set
(float[] source) set
(float x, float y) set
(int[] source) set_to
(int index, float arg) sin_wave
(int timeline, float s) sin_wave
(int timeline, float sx, float sy) sub
(float s) sub
(float sx, float sy) sub float valuesub_x
(float x) sub_y
(float y) float
sum()
sum of all componentst
(float y) tan()
return tangent of the vector directiontan
(float a_x, float a_y) return tangent of the vector directionreturn tangent of the vector directiontoString()
u
(float x) v
(float y) wave
(int timeline, float s) WAVEwave
(int timeline, float sx, float sy) x
(float x) y
(float y) Methods inherited from class rope.vector.vec
a, ab, abc, abcd, abcde, abcdef, alp, array, b, blu, bri, c, d, e, f, get, get, get_size, gre, hsb, hsba, hue, map, max, min, p, pq, q, random, random, random_next_gaussian, random_next_gaussian, random_next_gaussian, red, rgb, rgba, s, sat, size, st, stpq, t, u, uv, v, w, ww, www, wwww, wwwx, wwwy, wwwz, wwx, wwxw, wwxx, wwxy, wwxz, wwy, wwyw, wwyx, wwyy, wwyz, wwz, wwzw, wwzx, wwzy, wwzz, wx, wxw, wxww, wxwx, wxwy, wxwz, wxx, wxxw, wxxx, wxxy, wxxz, wxy, wxyw, wxyx, wxyy, wxyz, wxz, wxzw, wxzx, wxzy, wxzz, wy, wyw, wyww, wywx, wywy, wywz, wyx, wyxw, wyxx, wyxy, wyxz, wyy, wyyw, wyyx, wyyy, wyyz, wyz, wyzw, wyzx, wyzy, wz, wzw, wzww, wzwx, wzwy, wzwz, wzx, wzxw, wzxx, wzxy, wzxz, wzy, wzyw, wzyx, wzyy, wzyz, wzz, wzzw, wzzx, wzzy, wzzz, x, xw, xww, xwww, xwwx, xwwy, xwwz, xwx, xwxw, xwxx, xwxy, xwxz, xwy, xwyw, xwyx, xwyy, xwyz, xwz, xwzw, xwzx, xwzy, xwzz, xx, xxw, xxww, xxwx, xxwy, xxwz, xxx, xxxw, xxxx, xxxy, xxxz, xxy, xxyw, xxyx, xxyy, xxyz, xxz, xxzw, xxzx, xxzy, xxzz, xy, xyw, xyww, xywx, xywy, xywz, xyx, xyxw, xyxx, xyxy, xyxz, xyy, xyyw, xyyx, xyyy, xyyz, xyz, xyzw, xyzx, xyzy, xyzz, xz, xzw, xzww, xzwx, xzwy, xzwz, xzx, xzxw, xzxx, xzxy, xzxz, xzy, xzyw, xzyx, xzyy, xzyz, xzzw, xzzx, xzzy, xzzz, y, yw, yww, ywww, ywwx, ywwy, ywwz, ywx, ywxw, ywxx, ywxy, ywxz, ywy, ywyw, ywyx, ywyy, ywyz, ywz, ywzw, ywzx, ywzy, ywzz, yx, yxw, yxww, yxwx, yxwy, yxwz, yxx, yxxw, yxxx, yxxy, yxxz, yxy, yxyw, yxyx, yxyy, yxyz, yxz, yxzw, yxzx, yxzy, yxzz, yy, yyw, yyww, yywx, yywy, yywz, yyx, yyxw, yyxx, yyxy, yyxz, yyy, yyyw, yyyx, yyyy, yyyz, yyz, yyzw, yyzx, yyzy, yyzz, yz, yzw, yzww, yzwx, yzwy, yzwz, yzx, yzxw, yzxx, yzxy, yzxz, yzy, yzyw, yzyx, yzyy, yzyz, yzzw, yzzx, yzzy, yzzz, z, zw, zww, zwww, zwwx, zwwy, zwwz, zwx, zwxw, zwxx, zwxy, zwxz, zwy, zwyw, zwyx, zwyy, zwyz, zwz, zwzw, zwzx, zwzy, zwzz, zx, zxw, zxww, zxwx, zxwy, zxwz, zxx, zxxw, zxxx, zxxy, zxxz, zxy, zxyw, zxyx, zxyy, zxyz, zxz, zxzw, zxzx, zxzy, zxzz, zy, zyw, zyww, zywx, zywy, zywz, zyx, zyxw, zyxx, zyxy, zyxz, zyy, zyyw, zyyx, zyyy, zyyz, zyz, zyzw, zyzx, zyzy, zyzz, zz, zzw, zzww, zzwx, zzwy, zzwz, zzx, zzxw, zzxx, zzxy, zzxz, zzy, zzyw, zzyx, zzyy, zzyz, zzz, zzzw, zzzx, zzzy, zzzz
-
Constructor Details
-
vec2
public vec2() -
vec2
public vec2(float v) -
vec2
public vec2(float x, float y) -
vec2
-
vec2
-
vec2
public vec2(float[] source) -
vec2
public vec2(int[] source)
-
-
Method Details
-
set
- Parameters:
x
-y
-- Returns:
- this
-
set
-
set
-
set
-
set
-
set
-
set_to
-
inv
- Returns:
- inverse all argument
-
x
-
add_x
-
sub_x
-
mult_x
-
div_x
-
y
-
add_y
-
sub_y
-
mult_y
-
div_y
-
s
-
t
-
u
-
v
-
mult
multiply Vector by different float value- Parameters:
mx
-my
-- Returns:
- this vec2 mult by the arguments
-
mult
-
mult
-
mult
-
div
divide Vector by a float value- Parameters:
dx
-dy
-- Returns:
- this vec2 divide by the argument
-
div
-
div
-
div
-
add
add float value- Parameters:
ax
- floatay
- float- Returns:
- this vec2 result of addition
-
add
-
add
-
add
-
sub
sub float value- Parameters:
sx
- floatsy
- float- Returns:
- this vec2 result of substration
-
sub
-
sub
-
sub
-
dot
- Parameters:
v
- vec- Returns:
- the dot product between this and the target vec
-
dot
public float dot(float x, float y) -
pow
- Parameters:
pow
-- Returns:
- this vec2 by the power of argument.
-
pow
return the power result of this vector- Parameters:
pow_x
-pow_y
-- Returns:
-
normalize
Normalize vector- Parameters:
target
-- Returns:
-
normalize
-
map
- Parameters:
minIn
-maxIn
-minOut
-maxOut
-- Returns:
- Vec2
-
map
- Parameters:
minIn
-maxIn
-minOut
-maxOut
-- Returns:
-
jitter
JITTER- Parameters:
range
- int- Returns:
- Vec2 altered with a random gaussian effect
-
jitter
-
jitter
- Parameters:
range_x
- intrange_y
- int- Returns:
- Vec2 altered with a random gaussian effect
-
rand
random- Parameters:
max
- float- Returns:
- random value from 0 to float max for each argument
-
rand
random- Parameters:
min
- floatmax
- float- Returns:
- random value from float min to float max for each argument
-
rand
random- Parameters:
min
-max
-- Returns:
- random value from vec min to vec max for each argument
-
limit
- Parameters:
max
-- Returns:
-
constrain
-
constrain
-
constrain
-
constrain
Constrains a value to not exceed a maximum and minimum value.- Parameters:
min
-max
-- Returns:
-
wave
WAVE- Parameters:
timeline
- ints
- float speed for all vec arg- Returns:
- vec2 cosinus of the value
-
wave
- Parameters:
timeline
-sx
-sy
-- Returns:
-
cos_wave
- Parameters:
timeline
- ints
- float speed for all vec arg- Returns:
- vec2 cosinus of the value
-
cos_wave
- Parameters:
timeline
-sx
-sy
-- Returns:
-
sin_wave
- Parameters:
timeline
- ints
- float speed for all vec arg- Returns:
- vec2 sinus of the value
-
sin_wave
-
mod
- Parameters:
mod_x
-mod_y
-- Returns:
- return the modulo of each element in the same order
-
mod
-
mod
-
sum
public float sum()sum of all components- Returns:
- float
-
average
public float average()average of all componentsb- Returns:
- float
-
dist
return distance of the vector or length- Parameters:
target
-- Returns:
- float
-
dir
return normal cartesian angle coord- Returns:
- vec2
-
dir
return normal cartesian angle coord- Parameters:
a_x
-a_y
-- Returns:
- vec2
-
dir
return normal cartesian angle coord- Parameters:
origin
-- Returns:
- vec2
-
tan
return tangent of the vector direction- Returns:
- vec2
-
tan
return tangent of the vector direction- Parameters:
a_x
-a_y
-- Returns:
- vec2
-
tan
return tangent of the vector direction- Parameters:
target
-- Returns:
- vec2
-
angle
public float angle()Calculate the angle of rotation for this vector (only 2D vectors)- Returns:
- the float angle of rotation
-
angle
return heading angle- Parameters:
target
-- Returns:
- the float angle between this and the target vector
-
heading
public float heading()Calculate the angle of rotation for this vector (only 2D vectors)- Returns:
- the float angle of rotation
-
magSq
public float magSq()return square of vec- Returns:
- float
-
mag
public float mag()return square root of magnitude or length of vec2- Returns:
- float
-
mag
return mag between this vector and the target- Parameters:
target
-- Returns:
- float
-
equals
return true if the vector this is equals to vector target- Parameters:
target
- Vec2- Returns:
-
equals
public boolean equals(float target) return true if the vector this is equals to float target- Parameters:
target
- float- Returns:
-
equals
public boolean equals(float t_x, float t_y) * return true if the vector this is equals to float arguments- Parameters:
t_x
- floatt_y
- float- Returns:
-
compare
return true if the vector this and vector target are in the same vector area- Parameters:
target
-area
-- Returns:
-
in_polygon
https://forum.processing.org/one/topic/how-do-i-find-if-a-point-is-inside-a-complex-polygon.html http://paulbourke.net/geometry/ thks to Moggach and Paul Brook- Parameters:
points
- array of point who define the polygon.- Returns:
- true if the vec2 is in the polygon, false in the other case
-
in_line
https://forum.processing.org/two/discussion/90/point-and-line-intersection-detection refactoring from Quark Algorithm -
copy
copy() return all the component of vec- Returns:
- Vec2
-
toString
-