|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunlekker.geom.Vec2
public class Vec2
2D vector class.
Field Summary | |
---|---|
static float |
DEG
|
static float |
RADIAN
|
float |
x
Position |
float |
y
Position |
Constructor Summary | |
---|---|
Vec2()
Constructs a vector with x=0, y=0. |
|
Vec2(float _x,
float _y)
Constructs a vector with x=_x, y=_y. |
|
Vec2(Vec2 v)
Constructs a vector with x=v.x, y=v.y. |
Method Summary | |
---|---|
void |
add(float vx,
float vy)
Adds vx,vy to this vector. x = x + vx, y = y + vy |
void |
add(Vec2 v)
Adds vector v to this vector. x = x + v.x, y = y + v.y |
float |
angle()
Returns the orientation (angle) of the current vector in radians. |
static float |
angle(float x,
float y)
Returns the orientation (angle) of the vector in radians. |
void |
div(float d)
Divides the values of current vector by the float d. |
static float |
dot(Vec2 v1,
Vec2 v2)
Calculates dot product of two vectors v1 and v2. |
float |
findDistance(float _x,
float _y)
Returns distance between the point given by x,y and the point given by _x, _y. |
float |
findDistance(Vec2 v)
Returns distance between the point given by x,y and the point given by v.x, v.y. |
static Vec2 |
findIntersection(Vec2 p1,
Vec2 p2,
Vec2 p3,
Vec2 p4)
Ccalculates intersection and checks for parallel lines. |
float |
length()
Calculates length of vector. |
static float |
length(float x,
float y)
Calculates length of vector. |
void |
mult(float m)
Scales current vector by single scaling factor m. |
void |
mult(float vx,
float vy)
Multiplies values of vx,vy with values of vector v. |
void |
mult(Vec2 v)
Multiplies values of current vector with values of vector v. |
void |
norm()
Normalizes the current vector to be 1 unit in length. |
void |
norm(float m)
Normalizes the current vector to be m units in length. |
void |
rotate(float radians)
Rotates vector by a degree given in radians |
static Vec2 |
rotate(Vec2 v1,
float deg)
Rotates vector by a degree given in radians. |
void |
set(float tx,
float ty)
Sets vector to x = tx, y=ty. |
void |
set(Vec2 v)
Sets vector to the values of v. |
void |
sub(float vx,
float vy)
Subtracts vx,vy from this vector. x = x - vx, y = y - vy |
void |
sub(Vec2 v)
Subtracts vector v from this vector. x = x - v.x, y = y - v.y |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final float DEG
public static final float RADIAN
public float x
public float y
Constructor Detail |
---|
public Vec2()
public Vec2(float _x, float _y)
public Vec2(Vec2 v)
Method Detail |
---|
public void set(Vec2 v)
v
- public void set(float tx, float ty)
tx,
- typublic java.lang.String toString()
toString
in class java.lang.Object
public void add(Vec2 v)
v
- public void add(float vx, float vy)
vx,
- vypublic void sub(Vec2 v)
v
- public void sub(float vx, float vy)
vx,
- vypublic void mult(Vec2 v)
v
- public void mult(float vx, float vy)
vx,vy
- public void mult(float m)
m
- public void div(float d)
m
- public void norm()
public void norm(float m)
public float findDistance(Vec2 v)
v
- Point to compare with
public float findDistance(float _x, float _y)
_x
- X position to compare with_y
- Y position to compare with
public static float angle(float x, float y)
x
- y
-
public float angle()
public static Vec2 findIntersection(Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4)
p1
- First point of first linep2
- Second point of first linep3
- First point of first linep4
- Second point of first line
public static float dot(Vec2 v1, Vec2 v2)
public float length()
public static float length(float x, float y)
public void rotate(float radians)
radians
- Degree to rotate by, in radians.public static Vec2 rotate(Vec2 v1, float deg)
radians
- Degree to rotate by, in radians.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |