geomerative
Class RPoint

java.lang.Object
  extended by geomerative.RPoint

public class RPoint
extends java.lang.Object

RPoint is a very simple interface for creating, holding and drawing 2D points.


Field Summary
 float x
          The x coordinate of the point.
 float y
          The y coordinate of the point.
 
Constructor Summary
RPoint()
          Create a new point at (0, 0).
RPoint(double x, double y)
           
RPoint(float x, float y)
          Create a new point, given the coordinates.
RPoint(RPoint p)
          Copy a point.
 
Method Summary
 void add(RPoint p)
          Use this to add a vector to this point.
 float angle(RPoint p)
          Use this to obtain the angle between the vector and another vector
 RPoint cross(RPoint p)
          Use this to perform a cross product of the point with another point.
 float dist(RPoint p)
          Use this to obtain the distance between the vector and another vector
 float mult(RPoint p)
          Use this to multiply a vector to this point.
 float norm()
          Use this to obtain the norm of the point.
 void normalize()
          Use this to normalize the point.
 void print()
           
 void rotate(float angle)
           
 void rotate(float angle, float vx, float vy)
          Apply a rotation to the point, given the angle and optionally the coordinates of the center of rotation.
 void rotate(float angle, RPoint v)
          Apply a rotation to the point, given the angle and optionally the point of the center of rotation.
 void scale(float s)
          Apply a scaling to the point, given a scaling factor.
 void scale(float sx, float sy)
          Apply a scaling to the point, given the scaling factors.
 void scale(RPoint s)
          Apply a scaling to the point, given a scaling vector.
 float sqrnorm()
          Use this to obtain the square norm of the point.
 void sub(RPoint p)
          Use this to substract a vector to this point.
 void transform(RMatrix m)
          Use this to apply a transformation to the point.
 void translate(float tx, float ty)
          Apply a translation to the point.
 void translate(RPoint t)
          Apply a translation to the point.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public float x
The x coordinate of the point.


y

public float y
The y coordinate of the point.

Constructor Detail

RPoint

public RPoint(float x,
              float y)
Create a new point, given the coordinates.

Parameters:
x - the x coordinate of the new point
y - the y coordinate of the new point

RPoint

public RPoint(double x,
              double y)

RPoint

public RPoint()
Create a new point at (0, 0).


RPoint

public RPoint(RPoint p)
Copy a point.

Parameters:
p - the point we wish to make a copy of
Method Detail

transform

public void transform(RMatrix m)
Use this to apply a transformation to the point.

Parameters:
m - the transformation matrix to be applied

translate

public void translate(float tx,
                      float ty)
Apply a translation to the point.

Parameters:
tx - the coefficient of x translation
ty - the coefficient of y translation

translate

public void translate(RPoint t)
Apply a translation to the point.

Parameters:
t - the translation vector to be applied

rotate

public void rotate(float angle,
                   float vx,
                   float vy)
Apply a rotation to the point, given the angle and optionally the coordinates of the center of rotation.

Parameters:
angle - the angle of rotation to be applied
vx - the x coordinate of the center of rotation
vy - the y coordinate of the center of rotation

rotate

public void rotate(float angle)

rotate

public void rotate(float angle,
                   RPoint v)
Apply a rotation to the point, given the angle and optionally the point of the center of rotation.

Parameters:
angle - the angle of rotation to be applied
v - the position vector of the center of rotation

scale

public void scale(float sx,
                  float sy)
Apply a scaling to the point, given the scaling factors.

Parameters:
sx - the scaling coefficient over the x axis
sy - the scaling coefficient over the y axis

scale

public void scale(float s)
Apply a scaling to the point, given a scaling factor.

Parameters:
s - the scaling coefficient for a uniform scaling

scale

public void scale(RPoint s)
Apply a scaling to the point, given a scaling vector.

Parameters:
s - the scaling vector

normalize

public void normalize()
Use this to normalize the point. This means that after applying, it's norm will be equal to 1.


sub

public void sub(RPoint p)
Use this to substract a vector to this point.

Parameters:
p - the vector to substract

add

public void add(RPoint p)
Use this to add a vector to this point.

Parameters:
p - the vector to add

mult

public float mult(RPoint p)
Use this to multiply a vector to this point. This returns a float corresponding to the scalar product of both vectors.

Parameters:
p - the vector to multiply
Returns:
float, the result of the scalar product

cross

public RPoint cross(RPoint p)
Use this to perform a cross product of the point with another point. This returns a RPoint corresponding to the cross product of both vectors.

Parameters:
p - the vector to perform the cross product with
Returns:
RPoint, the resulting vector of the cross product

norm

public float norm()
Use this to obtain the norm of the point.

Returns:
float, the norm of the point

sqrnorm

public float sqrnorm()
Use this to obtain the square norm of the point.

Returns:
float, the norm of the point

angle

public float angle(RPoint p)
Use this to obtain the angle between the vector and another vector

Parameters:
p - the vector relative to which we want to evaluate the angle
Returns:
float, the angle between the two vectors

dist

public float dist(RPoint p)
Use this to obtain the distance between the vector and another vector

Parameters:
p - the vector relative to which we want to evaluate the distance
Returns:
float, the distance between the two vectors

print

public void print()


Geomerative by Ricard Marxer, http://www.ricardmarxer.com/geomerative/