

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object vec2d
public class vec2d
vec2d is a class representing the mathematical concept of twodimensional vector. In perticular we can consider a vec2d object to be a point in two dimensional space. This class includes the following operations:
This class is written for the Java tutorials of SE2AA4 (Winter 07).
Constructor Summary  

vec2d(double x,
double y)
Creates a new instance of vec2d 
Method Summary  

static vec2d 
add(vec2d v1,
vec2d v2)
Compute the sum of two vectors. 
vec2d 
clone()
clone another copy of itself this function makes sure the new copy have its own copy of data in memory other than those data of the original vector. 
static boolean 
coline(vec2d v1,
vec2d v2,
vec2d v3)
check if three points are in the same line of two dimensional space. 
double 
getLength()
Calculate the 2norm of the vector, which is the square root of the sum of the square of the coordinates. 
double 
getX()
Get the first coordinate of the vec2d object. 
double 
getY()
Get the second coordinate of the vec2d object. 
static vec2d 
mul(double r,
vec2d v)
scale a vector. 
void 
normalize()
Scale the vector to a unit vector. 
static vec2d 
proj(vec2d u,
vec2d v)
return the projection of vector u on vector v For two vectors u and v in linear algebra, the projection of u on v is the component of u such that in the same direction of v. 
static double 
triangleArea(vec2d v1,
vec2d v2,
vec2d v3)
Computer the area of a triangle. 
Methods inherited from class java.lang.Object 

equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Constructor Detail 

public vec2d(double x, double y)
x
 the first coordinate of the vectory
 the second coordinate of the vectorMethod Detail 

public vec2d clone()
clone
in class java.lang.Object
public double getX()
public double getY()
public double getLength()
public void normalize() throws java.lang.IllegalStateException
java.lang.IllegalStateException
public static vec2d add(vec2d v1, vec2d v2)
v1
 the first vector to be addedv2
 the second vector to be added
public static vec2d mul(double r, vec2d v)
r
 the ratio to scale the vectorv
 the vector to be scaled
public static boolean coline(vec2d v1, vec2d v2, vec2d v3)
v1
 the vector representing the first pointv2
 the vector representing the second pointv3
 the vector representing the third point
public static vec2d proj(vec2d u, vec2d v)
u
 the vector that we want to find the component by projecting onto
the otherv
 the vector on which u is projected
public static double triangleArea(vec2d v1, vec2d v2, vec2d v3)
v1
 the first vertexv2
 the second vertexv3
 the third vertex


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 