org.jcurl.math
Class MathVec

Package class diagram package MathVec
java.lang.Object
  extended by org.jcurl.math.MathVec

public final class MathVec
extends Object

Helper class that brings some (2D-)vector artihmetics.

Version:
$Id:MathVec.java 682 2007-08-12 21:25:04Z mrohrmoser $
Author:
M. Rohrmoser

Method Summary
static double abs2D(Point2D a)
           
static Point2D add(Point2D a, Point2D b, Point2D c)
           
static Point2D ensureInstance(Point2D template, Point2D c)
          Ensure c isn't null, if so create a new instance of the type of template.
static double[] gauss(double[][] a, double[] b, double[] x)
          Solve a linear equation of the form a*x=b.
(package private) static boolean isInside(double x, double a, double b, boolean allowSwap)
          Helper to check (inclusive) interval containment.
static double[] mult(double fact, double[] a, double[] b)
           
static Point2D mult(double fact, Point2D a, Point2D b)
           
static Point2D norm(Point2D a, Point2D dst)
           
static void rotate(AffineTransform t, double vx, double vy)
          TUNE JDK 1.6 brings an optimized AffineTransform.rotate(double)
static double scal(double[] a, double[] b)
           
static double scal(Point2D a, Point2D b)
           
static double sqr(double a)
           
static Point2D sub(Point2D a, Point2D b, Point2D dst)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

abs2D

public static final double abs2D(Point2D a)

add

public static final Point2D add(Point2D a,
                                Point2D b,
                                Point2D c)

ensureInstance

public static final Point2D ensureInstance(Point2D template,
                                           Point2D c)
Ensure c isn't null, if so create a new instance of the type of template.

Parameters:
template -
c -
Returns:
c or template.getClass().newInstance()

gauss

public static final double[] gauss(double[][] a,
                                   double[] b,
                                   double[] x)
Solve a linear equation of the form a*x=b.

See Numerische Mathematik, H. R. Schwarz, B. G. Teubner Verlag, 1998, S.22f.

Parameters:
a - coefficient matrix. Attention! All fields a[i][j] are overwritten!
b - constant vector. Attention! All fields b[i] are overwritten!
x - solution (max be null)
Returns:
x solution of a*x=b

isInside

static final boolean isInside(double x,
                              double a,
                              double b,
                              boolean allowSwap)
Helper to check (inclusive) interval containment. Robust against Double.NaN etc.

Parameters:
x -
a -
b -
allowSwap - may a > b?
Returns:
is x within a and b?

mult

public static final double[] mult(double fact,
                                  double[] a,
                                  double[] b)

mult

public static final Point2D mult(double fact,
                                 Point2D a,
                                 Point2D b)

norm

public static final Point2D norm(Point2D a,
                                 Point2D dst)

rotate

public static final void rotate(AffineTransform t,
                                double vx,
                                double vy)
TUNE JDK 1.6 brings an optimized AffineTransform.rotate(double)


scal

public static final double scal(double[] a,
                                double[] b)

scal

public static final double scal(Point2D a,
                                Point2D b)

sqr

public static final double sqr(double a)

sub

public static final Point2D sub(Point2D a,
                                Point2D b,
                                Point2D dst)


Copyright © 2005-2009 jcurl.org. All Rights Reserved.