Class VA

java.lang.Object
  |
  +--VA

public class VA
extends java.lang.Object

Author:
Erhan Oztop, 2001-2002

Source code by Erhan Oztop (erhan@atr.co.jp)
Copyright August 2002 via
University of Southern California Ph.D. publication copyright
This class is a collection of static Vector Algebra methods

Constructor Summary
VA()
           
 
Method Summary
(package private) static void _add(Point3d p1, Point3d p2)
          Modifies p1 so that p1=p1+p2
static void _Lrotate(Point3d p, Point3d p1, Point3d p2, double t)
          Rotates p around the line passing from p2 to p1 by t radians.
static void _normalize(Point3d p)
          Normalizes p
(package private) static void _resize(Point3d p0, Point3d p1, double sc)
           
static void _rotate(Point3d p, Point3d n, double t)
          rotates p around n by t radians.
(package private) static void _scale(Point3d p1, double sc)
          scales p1 to be equal to sc*p1
static void _slowrotate(Point3d p, Point3d n, double t)
          Rotates p around n by t radians.
(package private) static void _subtract(Point3d p1, Point3d p2)
          Modifies p1 so that p1=p1-p2
(package private) static void _translate(Point3d p1, double dx, double dy, double dz)
          translates p1 by (dx,dy,dz)
static void _Xrotate(Point3d p, double t)
          Rotate p around X axis by t radians
static void _Yrotate(Point3d p, double t)
          Rotate p around Y axis by t radians
static void _Zrotate(Point3d p, double t)
          Rotate p around Z axis by t radians
static double acos(Point3d p1, Point3d p2)
           
static double acos(Point3d p1, Point3d p0, Point3d q1, Point3d q0)
           
static double acos(java.awt.Point p1, java.awt.Point p0, java.awt.Point q1, java.awt.Point q0)
           
static double acosD(Point3d p1, Point3d p0, Point3d q1, Point3d q0)
           
static double acosD(java.awt.Point p1, java.awt.Point p0, java.awt.Point q1, java.awt.Point q0)
           
(package private) static Point3d add(Point3d p1, Point3d p2)
          Returns p1+p2
static void addto(double[][] M, int im, int jm, double[][] C)
          M=M+C, the size of the matrices: im x jm
(package private) static Point3d center(Point3d p0, Point3d p)
           
(package private) static double cos(Point3d p1, Point3d p2)
          Returns the cosine of the angle between p1 & p2.
static double cos(Point3d p1, Point3d p0, Point3d q1, Point3d q0)
           
static double cos(java.awt.Point p1, java.awt.Point p0, java.awt.Point q1, java.awt.Point q0)
           
static double cosSin(double cosx, double sinx)
          Returns the angle determined by given cosine and sine.
(package private) static Point3d cross(Point3d p1, Point3d p2)
          Returns p1xp2.
(package private) static double dist(double x0, double y0, double x1, double y1)
          Returns distance between points (x0,y0),(x1,y1).
(package private) static double dist(int x0, int y0, int x1, int y1)
          Returns distance between (int) points (x0,y0),(x1,y1).
(package private) static double dist(Point3d p1, Point3d p2)
          Returns distance between points p1 & p2 of Point3d class.
(package private) static double dist(java.awt.Point p0, java.awt.Point p1)
          Returns distance between 2d two points.
(package private) static double dist2(int x0, int y0, int x1, int y1)
          Returns square of the distance between (int) points (x0,y0),(x1,y1).
(package private) static double dist2(Point3d p1, Point3d p2)
          Returns the square of the distance between points p1 & p2 of Point3d class.
(package private) static double inner(Point3d p1, Point3d p2)
          Returns p1.p2.
static Point3d Lrotate(Point3d p, Point3d p1, Point3d p2, double t)
          Returns the rotated version of p around the line passing from p2 to p1 by t radians.
static void multiadd(double[][] M, double[] v, int im, int jm, double[] r)
          compute r=r+Mv, im size of r, jm is size of v (M is imxjm)
static void multiadd(double[][] M, double[] v, int im, int jm, double[] r, double C)
          compute r=r+Mv+C, im size of r, jm is size of v (M is imxjm)
static void multiply(double[][] M, double[] v, int im, int jm, double[] r)
          compute r[]=M[][]*v[].
static void multiply(double[][] M, double[] v, int im, int jm, double[] r, double C)
          compute r[]=M[][]*v[]+C.
(package private) static double norm(Point3d p1)
          Returns |p1|.
(package private) static Point3d normal(Point3d p1, Point3d p2, Point3d p3)
          Returns the normal of the plane spanned by p1-p2,p2-p3
static Point3d normalize(Point3d p)
          Returns a normalized version of p
static Point3d polar(double meridian, double parallel, double radius)
           
static Point3d polor2rect(Point3d v)
          v represents the triple (meridian, parallel, radius); the return is the rectangular coordinates.
(package private) static Point3d proj(Point3d b, Point3d a)
          Projection of vector a on b.
(package private) static Point3d promote3d(java.awt.Point p)
          Returns a Point3d equal to (p,0)
static Point3d rect2polar(Point3d p)
           
static Point3d rotate(Point3d p, Point3d n, double t)
          Returns the rotated version of p around n by t radians.
(package private) static Point3d scale(Point3d p1, double sc)
          Returns a new Point3d equal to sc*p1
static void setMatrix(double[][] a, double[][] b)
          a=b.
static void setMatrix(double[][] a, double[][] b, int rows, int cols)
          a=b.
static double[][] STAR(Point3d p)
          Returns the matrix [0 -p.z p.y; p.z 0 -p x; -p.y p.x 0] .
(package private) static Point3d subtract(Point3d p1, Point3d p2)
          Returns p1-p2
(package private) static Point3d symetric(Point3d org, Point3d p)
           
(package private) static Point3d translate(Point3d p1, double dx, double dy, double dz)
          Returns a new Point3d equal p1+(dx,dy,dz)
(package private) static double[][] transpose(double[][] M)
           
static Point3d Xrotate(Point3d p, double t)
          Returns rotated version of p around X axis by t radians
static Point3d Yrotate(Point3d p, double t)
          Returns rotated version of p around Y axis by t radians
static Point3d zap2Y(Point3d n)
           
static boolean zero(Point3d p1)
          Check for zero vector.
static Point3d Zrotate(Point3d p, double t)
          Returns rotated version of p around Z axis by t radians
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

VA

public VA()
Method Detail

center

static Point3d center(Point3d p0,
                      Point3d p)

symetric

static Point3d symetric(Point3d org,
                        Point3d p)

dist

static double dist(int x0,
                   int y0,
                   int x1,
                   int y1)
Returns distance between (int) points (x0,y0),(x1,y1).

dist2

static double dist2(int x0,
                    int y0,
                    int x1,
                    int y1)
Returns square of the distance between (int) points (x0,y0),(x1,y1).

dist

static double dist(java.awt.Point p0,
                   java.awt.Point p1)
Returns distance between 2d two points.

dist

static double dist(double x0,
                   double y0,
                   double x1,
                   double y1)
Returns distance between points (x0,y0),(x1,y1).

dist

static double dist(Point3d p1,
                   Point3d p2)
Returns distance between points p1 & p2 of Point3d class.

dist2

static double dist2(Point3d p1,
                    Point3d p2)
Returns the square of the distance between points p1 & p2 of Point3d class.

_resize

static void _resize(Point3d p0,
                    Point3d p1,
                    double sc)

scale

static Point3d scale(Point3d p1,
                     double sc)
Returns a new Point3d equal to sc*p1

_scale

static void _scale(Point3d p1,
                   double sc)
scales p1 to be equal to sc*p1

translate

static Point3d translate(Point3d p1,
                         double dx,
                         double dy,
                         double dz)
Returns a new Point3d equal p1+(dx,dy,dz)

_translate

static void _translate(Point3d p1,
                       double dx,
                       double dy,
                       double dz)
translates p1 by (dx,dy,dz)

add

static Point3d add(Point3d p1,
                   Point3d p2)
Returns p1+p2

_add

static void _add(Point3d p1,
                 Point3d p2)
Modifies p1 so that p1=p1+p2

transpose

static double[][] transpose(double[][] M)

subtract

static Point3d subtract(Point3d p1,
                        Point3d p2)
Returns p1-p2

_subtract

static void _subtract(Point3d p1,
                      Point3d p2)
Modifies p1 so that p1=p1-p2

cross

static Point3d cross(Point3d p1,
                     Point3d p2)
Returns p1xp2. (cross product of p1 & p2)

normal

static Point3d normal(Point3d p1,
                      Point3d p2,
                      Point3d p3)
Returns the normal of the plane spanned by p1-p2,p2-p3

inner

static double inner(Point3d p1,
                    Point3d p2)
Returns p1.p2. (inner product of p1 & p2)

norm

static double norm(Point3d p1)
Returns |p1|. (norm -length- of p1)

cos

static double cos(Point3d p1,
                  Point3d p2)
Returns the cosine of the angle between p1 & p2. A zero vector will result a zero angle A zero vector will result a zero angle that is 1 will be returned.

proj

static Point3d proj(Point3d b,
                    Point3d a)
Projection of vector a on b.

cos

public static double cos(Point3d p1,
                         Point3d p0,
                         Point3d q1,
                         Point3d q0)

cos

public static double cos(java.awt.Point p1,
                         java.awt.Point p0,
                         java.awt.Point q1,
                         java.awt.Point q0)

acos

public static double acos(Point3d p1,
                          Point3d p2)

acos

public static double acos(Point3d p1,
                          Point3d p0,
                          Point3d q1,
                          Point3d q0)

acos

public static double acos(java.awt.Point p1,
                          java.awt.Point p0,
                          java.awt.Point q1,
                          java.awt.Point q0)

acosD

public static double acosD(Point3d p1,
                           Point3d p0,
                           Point3d q1,
                           Point3d q0)

acosD

public static double acosD(java.awt.Point p1,
                           java.awt.Point p0,
                           java.awt.Point q1,
                           java.awt.Point q0)

promote3d

static Point3d promote3d(java.awt.Point p)
Returns a Point3d equal to (p,0)

_normalize

public static void _normalize(Point3d p)
Normalizes p

normalize

public static Point3d normalize(Point3d p)
Returns a normalized version of p

zero

public static boolean zero(Point3d p1)
Check for zero vector. If zero, true is returned else false is returned.

cosSin

public static double cosSin(double cosx,
                            double sinx)
Returns the angle determined by given cosine and sine. Returned angle is in the range [-pi,pi]

Zrotate

public static Point3d Zrotate(Point3d p,
                              double t)
Returns rotated version of p around Z axis by t radians

Xrotate

public static Point3d Xrotate(Point3d p,
                              double t)
Returns rotated version of p around X axis by t radians

Yrotate

public static Point3d Yrotate(Point3d p,
                              double t)
Returns rotated version of p around Y axis by t radians

_Zrotate

public static void _Zrotate(Point3d p,
                            double t)
Rotate p around Z axis by t radians

_Xrotate

public static void _Xrotate(Point3d p,
                            double t)
Rotate p around X axis by t radians

_Yrotate

public static void _Yrotate(Point3d p,
                            double t)
Rotate p around Y axis by t radians

zap2Y

public static Point3d zap2Y(Point3d n)

rotate

public static Point3d rotate(Point3d p,
                             Point3d n,
                             double t)
Returns the rotated version of p around n by t radians. The parameters are unchanged.

_slowrotate

public static void _slowrotate(Point3d p,
                               Point3d n,
                               double t)
Rotates p around n by t radians. Note that this is slow and uses rotate(). Instead _rotate() should be used.
See Also:
_rotate(Point3d, Point3d, double), rotate(Point3d, Point3d, double)

_rotate

public static void _rotate(Point3d p,
                           Point3d n,
                           double t)
rotates p around n by t radians. p modified

_Lrotate

public static void _Lrotate(Point3d p,
                            Point3d p1,
                            Point3d p2,
                            double t)
Rotates p around the line passing from p2 to p1 by t radians.

Lrotate

public static Point3d Lrotate(Point3d p,
                              Point3d p1,
                              Point3d p2,
                              double t)
Returns the rotated version of p around the line passing from p2 to p1 by t radians.

setMatrix

public static void setMatrix(double[][] a,
                             double[][] b)
a=b. No size check done. The array creatation size of a[][] is used

setMatrix

public static void setMatrix(double[][] a,
                             double[][] b,
                             int rows,
                             int cols)
a=b. No size check done. rows,cols defines the loop boundry

STAR

public static double[][] STAR(Point3d p)
Returns the matrix [0 -p.z p.y; p.z 0 -p x; -p.y p.x 0] . if R is an orientation matrix then dR/dt is given by dR/dt=STAR(angular velocity)*R where * is matrix multiplication

polor2rect

public static Point3d polor2rect(Point3d v)
v represents the triple (meridian, parallel, radius); the return is the rectangular coordinates. The polor coordinates are defined on a left handed rectangular coordinate system (+x,+y as in 2D +z going into the screen) as : The sphere stayin on the origin. 0 meridian is in +x+y semi-plane pi/2 meridian is on the +y+z semiplane pi meridian is on -x+y semiplane and so on. The 0 parallel is the degenerate circle at the north pole (+y) and pi parallel is the south pole. pi/2 parallel line is on xz plane. Meridian range is [0:2pi] (or [-pi:pi]) parallel range is [0:pi]

polar

public static Point3d polar(double meridian,
                            double parallel,
                            double radius)

rect2polar

public static Point3d rect2polar(Point3d p)

multiply

public static void multiply(double[][] M,
                            double[] v,
                            int im,
                            int jm,
                            double[] r)
compute r[]=M[][]*v[]. r=Mv, im size of r, jm is size of v (M is imxjm)

multiply

public static void multiply(double[][] M,
                            double[] v,
                            int im,
                            int jm,
                            double[] r,
                            double C)
compute r[]=M[][]*v[]+C. r=Mv, im size of r, jm is size of v (M is imxjm)

multiadd

public static void multiadd(double[][] M,
                            double[] v,
                            int im,
                            int jm,
                            double[] r)
compute r=r+Mv, im size of r, jm is size of v (M is imxjm)

multiadd

public static void multiadd(double[][] M,
                            double[] v,
                            int im,
                            int jm,
                            double[] r,
                            double C)
compute r=r+Mv+C, im size of r, jm is size of v (M is imxjm)

addto

public static void addto(double[][] M,
                         int im,
                         int jm,
                         double[][] C)
M=M+C, the size of the matrices: im x jm