|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.grogra.vecmath.Math2
public final class Math2
This class contains a set of mathematical functions and constants, including random and noise generators, linear algebra, and table-based trigonometric functions.
Field Summary | |
---|---|
static float |
EPS
The very small number epsilon. 1E-05 |
static float |
EPSILON
The very small number epsilon. 1E-09 |
static float |
M_1_2PI
The constant 1 / (2 π) as float . |
static float |
M_1_PI
The constant 1 / π as float . |
static float |
M_2PI
The constant 2 π as float . |
static float |
M_PI
The constant π as float . |
static float |
M_PI_2
The constant π / 2 as float . |
static int |
nbSkySegments
Numbers of skysegments for the turtlesky |
static Vector3d[] |
turtsky
Define the turtlesky |
Method Summary | |
---|---|
static float |
absthgs(Vector3d ss,
Vector3d rr,
Vector3d sa,
Vector3d se)
|
static float |
abstphg(Vector3d pp,
Vector3d ss,
Vector3d rr)
|
static float |
abstpp(Vector3d av,
Vector3d ev)
Computated the distance between two vectors |
static float |
abstps(Vector3d pp,
Vector3d sa,
Vector3d se)
Calculates the distance between the point pp and the piece of straight line delimited by sa and se. |
static int |
binomial(int n,
int k)
|
static float |
ccos(char c)
Returns the cosine of the argument. |
static double |
clamp(double value,
double min,
double max)
|
static float |
clamp(float value,
float min,
float max)
|
static int |
clamp(int value,
int min,
int max)
|
static long |
clamp(long value,
long min,
long max)
|
static double |
closestConnection(Tuple3d p,
Vector3d v,
Tuple3d q)
|
static float |
csin(char c)
Returns the sine of the argument. |
static void |
cutCone(Vector3d ss,
float alpha,
Vector3d pp,
Vector3d qq,
CutConeParameter ccp)
|
static void |
cutRay2(float a1,
float a2,
float r1,
float r2,
float u1,
float u2,
float v1,
float v2,
CutRay2Parameter crp)
|
static void |
decomposeQR(Matrix3d r,
Matrix3d q)
Computes a QR decomposition of r . |
static float |
determinate3(Vector3d a1,
Vector3d a2,
Vector3d a3)
|
static double |
distance(Tuple3d p,
Vector3d v,
Tuple3d q)
|
static void |
dNoise(Tuple3f out,
float x,
float y,
float z)
This method represents the derivative of a Perlin-style 3D noise function. |
static double |
dot(Tuple3d a,
Tuple3d b)
|
static double |
dot(Tuple3d p,
Tuple3d q,
Tuple3d v)
Computes the scalar product (p - q) v |
static float |
dot(Tuple3f a,
Tuple3d b)
|
static float |
dot(Tuple3f a,
Tuple3f b)
|
static void |
dTurbulence(Tuple3f out,
float x,
float y,
float z,
int octaves,
float lambda,
float omega)
|
static double |
estimateScaleSquared(Matrix4d transformation)
|
static int |
factorial(int n)
|
static int |
floor(double x)
|
static float |
fresnel(Vector3f normal,
Vector3f in,
float iorRatio,
Vector3f reflectedOut,
Vector3f transmittedOut)
Computes reflected and transmitted directions according to Fresnel's formulas. |
static float |
gamma(float x)
|
static void |
getBeginAndEndOfShoot(Matrix4d m,
double length,
Vector3d beginOfShoot,
Vector3d endOfShoot)
|
static void |
getBeginOfShoot(Matrix4d m,
Vector3d beginOfShoot)
|
static void |
getEndOfShoot(Matrix4d m,
double length,
Vector3d endOfShoot)
|
static void |
getOrthogonal(Tuple3d in,
Tuple3d out)
Computes an orthogonal vector to in . |
static void |
getOrthogonal(Tuple3f in,
Tuple3f out)
Computes an orthogonal vector to in . |
static void |
getOrthogonalBasis(Tuple3d in,
Matrix3d out,
boolean orthonormal)
Computes an orthogonal basis. |
static void |
getOrthogonalBasis(Tuple3f in,
Matrix3f out,
boolean orthonormal)
Computes an orthogonal basis. |
static double |
intersectLineWithFrustum(double px,
double py,
double pz,
double dx,
double dy,
double dz,
double ax,
double ay,
double az,
double top,
double base,
double tan)
Determines the fraction of a line (p,d) which intersects a frustum. |
static double |
intersectLineWithFrustum(Point3d point,
Vector3d direction,
Point3d origin,
Vector3d axis,
double top,
double base,
double tan)
|
static void |
invertAffine(Matrix34d in,
Matrix4d out)
|
static void |
invertAffine(Matrix3d in,
Matrix3d out)
|
static void |
invertAffine(Matrix3f in,
Matrix3f out)
|
static void |
invertAffine(Matrix4d in,
Matrix4d out)
|
static void |
invertAffine(Matrix4f in,
Matrix4f out)
|
static void |
invMul(Matrix3d t,
Tuple3d v)
|
static void |
invTransformPoint(Matrix34d t,
Tuple3d p)
|
static void |
invTransformPoint(Matrix3d t,
Tuple2d p)
|
static void |
invTransformPoint(Matrix3f t,
Tuple2f p)
|
static void |
invTransformPoint(Matrix4d t,
Tuple3d p)
|
static void |
invTransformPointAndVector(Matrix4d t,
Tuple3d p,
Tuple3d v)
|
static void |
invTransformVector(Matrix34d t,
Tuple3d v)
|
static void |
invTransformVector(Matrix3d t,
Tuple2d v)
|
static void |
invTransformVector(Matrix3f t,
Tuple2f v)
|
static void |
invTransformVector(Matrix4d t,
Tuple3d v)
|
static boolean |
isInsideConeT(double px,
double py,
double pz,
double ax,
double ay,
double az,
double tipDistance,
double capDistance,
double tan)
Determines if a point p lies inside a (part of a) cone. |
static boolean |
isInsideConeT(double px,
double py,
double pz,
double ox,
double oy,
double oz,
double ax,
double ay,
double az,
double tipDistance,
double capDistance,
double tan)
|
static boolean |
isNullVector(Vector3d a)
Test of all parts of the vector are null |
static boolean |
lessThan(Tuple3d a,
Tuple3d b)
|
static boolean |
lessThanOrEqual(Tuple3d a,
Tuple3d b)
|
static void |
lmul(Matrix3d rot,
Matrix34d m)
|
static void |
makeAffine(Matrix3d m)
|
static void |
makeAffine(Matrix3f m)
|
static void |
makeAffine(Matrix4d m)
|
static void |
makeAffine(Matrix4f m)
|
static void |
max(Tuple2d max,
Tuple2d t)
|
static void |
max(Tuple2f max,
Tuple2f t)
|
static void |
max(Tuple3d max,
Tuple3d t)
|
static void |
max(Tuple3f max,
Tuple3f t)
|
static void |
min(Tuple2d min,
Tuple2d t)
|
static void |
min(Tuple2f min,
Tuple2f t)
|
static void |
min(Tuple3d min,
Tuple3d t)
|
static void |
min(Tuple3f min,
Tuple3f t)
|
static void |
mul(Tuple3d out,
Tuple3d a,
Tuple3d b)
|
static void |
mul(Tuple3f out,
Tuple3f a,
Tuple3f b)
|
static void |
mulAffine(Matrix3d out,
Matrix3d l,
Matrix3d r)
|
static void |
mulAffine(Matrix4d out,
Matrix4d l,
Matrix4d r)
|
static long |
nextRandom(long seed)
Returns the next 48-bit pseudo-random number based on the previous pseudo-random number seed . |
static float |
noise(float x,
float y,
float z)
This method represents a Perlin-style 3D noise function. |
static void |
normalize(Vector3d aVector)
Normalizes this vector in place. |
static void |
normalize(Vector3f aVector)
Normalizes this vector in place. |
static void |
onbco(Vector3d result,
Vector3d a,
Vector3d ba1,
Vector3d ba2,
Vector3d ba3)
|
static boolean |
parallelVector(Vector3d a1,
Vector3d a2)
|
static long |
pow(int a,
int b)
|
static boolean |
quadricIntersection(double a00,
double a01,
double a02,
double a11,
double a12,
double a22,
double b0,
double b1,
double b2,
double c,
Point3d p,
Vector3d d,
double[] lambda)
|
static char |
random(char index)
This method represents a random permutation of char
values. |
static int |
roundUpNextPowerOfTwo(int v)
Calculate the next power of two greater or equal than v. |
static void |
setAffine(Matrix4d out,
Matrix4d in)
|
static void |
setAffineTransform(java.awt.geom.AffineTransform out,
Matrix3d in)
|
static void |
setMatrix3d(Matrix3d out,
java.awt.geom.AffineTransform in)
|
static double |
shortestConnection(Tuple3d p1,
Vector3d v1,
Tuple3d p2,
Vector3d v2,
double[] lambda)
Computes the shortest straight connection between two lines. |
static double |
shortestConnection(Tuple3d p1,
Vector3d v1,
Tuple3f p2,
Vector3f v2,
double[] lambda)
Computes the shortest straight connection between two lines. |
static float |
shortestConnection(Tuple3f p1,
Vector3f v1,
Tuple3f p2,
Vector3f v2,
float[] lambda)
Computes the shortest straight connection between two lines. |
static float |
sin(float x)
Returns the sine of the argument. |
static float |
sin01(float x)
Returns the sine of the argument. |
static int |
skySegment(Vector3d rv)
|
static float[] |
toFloatArray(Tuple3d p)
|
static float[] |
toFloatArray(Tuple4d p)
|
static float[] |
toFloatArray(Tuple4f p)
|
static void |
transformPoint(Matrix3d t,
Tuple2d p)
|
static void |
transformPoint(Matrix4d t,
Tuple3d p)
|
static void |
transformPoint(Matrix4d t,
Tuple3d p,
Tuple3d out)
|
static void |
transformPoint(Matrix4f t,
Tuple3f p)
|
static void |
transformTranspose(Matrix3d t,
Tuple3d v)
|
static void |
transformVector(Matrix3d t,
Tuple2d v)
|
static void |
transformVector(Matrix4d t,
Tuple3d v)
|
static void |
transformVector(Matrix4f t,
Tuple3f v)
|
static float |
turbulence(float x,
float y,
float z,
int octaves,
float lambda,
float omega)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final float EPS
public static final float EPSILON
public static float M_1_2PI
float
.
public static float M_1_PI
float
.
public static float M_2PI
float
.
public static float M_PI
float
.
public static float M_PI_2
float
.
public static int nbSkySegments
public static final Vector3d[] turtsky
Method Detail |
---|
public static float absthgs(Vector3d ss, Vector3d rr, Vector3d sa, Vector3d se)
public static float abstphg(Vector3d pp, Vector3d ss, Vector3d rr)
public static float abstpp(Vector3d av, Vector3d ev)
av
- first vectorev
- second vector
public static float abstps(Vector3d pp, Vector3d sa, Vector3d se)
pp
- Pointsa
- Begin of the straight linese
- End of the straight line
public static int binomial(int n, int k)
public static float ccos(char c)
char
values is mapped to [0, 2 π), i.e., the angle in radians
is 2 π c
/ 0x10000. This method uses a pre-computed
table.
c
- an angle
public static double clamp(double value, double min, double max)
public static float clamp(float value, float min, float max)
public static int clamp(int value, int min, int max)
public static long clamp(long value, long min, long max)
public static double closestConnection(Tuple3d p, Vector3d v, Tuple3d q)
public static float csin(char c)
char
values is mapped to [0, 2 π), i.e., the angle in radians
is 2 π c
/ 0x10000. This method uses a pre-computed
table.
c
- an angle
public static void cutCone(Vector3d ss, float alpha, Vector3d pp, Vector3d qq, CutConeParameter ccp)
public static void cutRay2(float a1, float a2, float r1, float r2, float u1, float u2, float v1, float v2, CutRay2Parameter crp)
public static void decomposeQR(Matrix3d r, Matrix3d q)
r
. The non-singular matrix
a
to be composed is the parameter r
.
This method computes r
and q
such that
a = q * r
, q
is an orthogonal matrix,
and r
an upper triangular matrix. The signs of
r.m00
and r.m11
are positive. The sign
of r.m22
is the sign of det(a)
. As a
consequence, det(q) == 1
, so q
is a
pure rotation.
r
- the input for the matrix to compose and the output for rq
- the output for qpublic static float determinate3(Vector3d a1, Vector3d a2, Vector3d a3)
public static double distance(Tuple3d p, Vector3d v, Tuple3d q)
public static void dNoise(Tuple3f out, float x, float y, float z)
out
- the computed derivate at (x, y, z) is placed in herex
- x-coordinatey
- x-coordinatez
- x-coordinatepublic static double dot(Tuple3d a, Tuple3d b)
public static double dot(Tuple3d p, Tuple3d q, Tuple3d v)
(p - q) v
p
- a pointq
- point which is subtracted from p
v
- a vector
(p - q) v
public static float dot(Tuple3f a, Tuple3d b)
public static float dot(Tuple3f a, Tuple3f b)
public static void dTurbulence(Tuple3f out, float x, float y, float z, int octaves, float lambda, float omega)
public static double estimateScaleSquared(Matrix4d transformation)
public static int factorial(int n)
public static int floor(double x)
public static float fresnel(Vector3f normal, Vector3f in, float iorRatio, Vector3f reflectedOut, Vector3f transmittedOut)
normal
- the normal unit vector of the surfacein
- the negated direction unit vector of the incoming rayiorRatio
- the index of refraction of the surface side where
the normal vector points into, divided by the index of refraction
of the opposite sidereflectedOut
- the computed unit vector of the reflection directiontransmittedOut
- the computed unit vector of the transmission direction
public static float gamma(float x)
public static void getBeginAndEndOfShoot(Matrix4d m, double length, Vector3d beginOfShoot, Vector3d endOfShoot)
public static void getBeginOfShoot(Matrix4d m, Vector3d beginOfShoot)
public static void getEndOfShoot(Matrix4d m, double length, Vector3d endOfShoot)
public static void getOrthogonal(Tuple3d in, Tuple3d out)
in
. The computed vector
is written to out
, which may be the same
reference as in
.
in
- an input vectorout
- the computed orthogonal vector is placed in herepublic static void getOrthogonal(Tuple3f in, Tuple3f out)
in
. The computed vector
is written to out
, which may be the same
reference as in
.
in
- an input vectorout
- the computed orthogonal vector is placed in herepublic static void getOrthogonalBasis(Tuple3d in, Matrix3d out, boolean orthonormal)
out
are unit vectors, the third
column equals in
if orthonormal
is false
, otherwise it equals the unit vector
in the direction of in
. Thus, out
represents a coordinate transformation which transforms the local
z-axis into the direction of in
.
in
- the direction of the local z-axisout
- the computed matrixorthonormal
- compute an orthonormal matrix?public static void getOrthogonalBasis(Tuple3f in, Matrix3f out, boolean orthonormal)
out
are unit vectors, the third
column equals in
if orthonormal
is false
, otherwise it equals the unit vector
in the direction of in
. Thus, out
represents a coordinate transformation which transforms the local
z-axis into the direction of in
.
in
- the direction of the local z-axisout
- the computed matrixorthonormal
- compute an orthonormal matrix?public static double intersectLineWithFrustum(double px, double py, double pz, double dx, double dy, double dz, double ax, double ay, double az, double top, double base, double tan)
The frustum is specified by the cone from which it is obtained by cutting away the top: The cone's tip is located at the origin, its axis is given by a and points to the center of the cone's cap which is located at base * a. The half-angle of the cone is specified by its tangent. The cutting plane for obtaining the frustum is located at the position top * a.
The line is specified by its origin p and its vector d from the origin to the end.
px
- x coordinate of line origin ppy
- y coordinate of line origin ppz
- z coordinate of line origin pdx
- x coordinate of line vector ddy
- y coordinate of line vector ddz
- z coordinate of line vector dax
- x coordinate of cone axis aay
- y coordinate of cone axis aaz
- z coordinate of cone axis atop
- relative position of frustum's top cap along axisbase
- relative position of frustum's base cap along axistan
- tangent of cone's half angle
public static double intersectLineWithFrustum(Point3d point, Vector3d direction, Point3d origin, Vector3d axis, double top, double base, double tan)
public static void invertAffine(Matrix34d in, Matrix4d out)
public static void invertAffine(Matrix3d in, Matrix3d out)
public static void invertAffine(Matrix3f in, Matrix3f out)
public static void invertAffine(Matrix4d in, Matrix4d out)
public static void invertAffine(Matrix4f in, Matrix4f out)
public static void invMul(Matrix3d t, Tuple3d v)
public static void invTransformPoint(Matrix34d t, Tuple3d p)
public static void invTransformPoint(Matrix3d t, Tuple2d p)
public static void invTransformPoint(Matrix3f t, Tuple2f p)
public static void invTransformPoint(Matrix4d t, Tuple3d p)
public static void invTransformPointAndVector(Matrix4d t, Tuple3d p, Tuple3d v)
public static void invTransformVector(Matrix34d t, Tuple3d v)
public static void invTransformVector(Matrix3d t, Tuple2d v)
public static void invTransformVector(Matrix3f t, Tuple2f v)
public static void invTransformVector(Matrix4d t, Tuple3d v)
public static boolean isInsideConeT(double px, double py, double pz, double ax, double ay, double az, double tipDistance, double capDistance, double tan)
px
- x coordinate of point ppy
- y coordinate of point ppz
- z coordinate of point pax
- x coordinate of cone axis aay
- y coordinate of cone axis aaz
- z coordinate of cone axis atipDistance
- distance to the tip (in units of axis)capDistance
- distance of the cap (in units of axis)tan
- tangent of cone's half angle
public static boolean isInsideConeT(double px, double py, double pz, double ox, double oy, double oz, double ax, double ay, double az, double tipDistance, double capDistance, double tan)
public static boolean isNullVector(Vector3d a)
a
- the vector to test
public static boolean lessThan(Tuple3d a, Tuple3d b)
public static boolean lessThanOrEqual(Tuple3d a, Tuple3d b)
public static void lmul(Matrix3d rot, Matrix34d m)
public static void makeAffine(Matrix3d m)
public static void makeAffine(Matrix3f m)
public static void makeAffine(Matrix4d m)
public static void makeAffine(Matrix4f m)
public static void max(Tuple2d max, Tuple2d t)
public static void max(Tuple2f max, Tuple2f t)
public static void max(Tuple3d max, Tuple3d t)
public static void max(Tuple3f max, Tuple3f t)
public static void min(Tuple2d min, Tuple2d t)
public static void min(Tuple2f min, Tuple2f t)
public static void min(Tuple3d min, Tuple3d t)
public static void min(Tuple3f min, Tuple3f t)
public static void mul(Tuple3d out, Tuple3d a, Tuple3d b)
public static void mul(Tuple3f out, Tuple3f a, Tuple3f b)
public static void mulAffine(Matrix3d out, Matrix3d l, Matrix3d r)
public static void mulAffine(Matrix4d out, Matrix4d l, Matrix4d r)
public static long nextRandom(long seed)
seed
. The sequence of numbers is the
same as the sequence computed by java.util.Random
:
nextRandom = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);However, this method should be slightly faster because it does not have to deal with multi-threading issues.
Pseudo-random int
s of n
bits should be
obtained from the returned value by the formula
(int) (nextRandom >>> (48 - n))
.
seed
- previous number of sequence
public static float noise(float x, float y, float z)
x
- x-coordinatey
- x-coordinatez
- x-coordinate
public static void normalize(Vector3d aVector)
aVector
- The normalized vectorpublic static void normalize(Vector3f aVector)
aVector
- The normalized vectorpublic static void onbco(Vector3d result, Vector3d a, Vector3d ba1, Vector3d ba2, Vector3d ba3)
public static boolean parallelVector(Vector3d a1, Vector3d a2)
public static long pow(int a, int b)
public static boolean quadricIntersection(double a00, double a01, double a02, double a11, double a12, double a22, double b0, double b1, double b2, double c, Point3d p, Vector3d d, double[] lambda)
public static char random(char index)
char
values. I.e., it is a bijective map on char
s, the
mapping being defined by a pseudo-random number generator. The
mapping remains the same between different invocations of the
Java Virtual Machine.
index
- an index into a permutation table
public static int roundUpNextPowerOfTwo(int v)
v
-
public static void setAffine(Matrix4d out, Matrix4d in)
public static void setAffineTransform(java.awt.geom.AffineTransform out, Matrix3d in)
public static void setMatrix3d(Matrix3d out, java.awt.geom.AffineTransform in)
public static double shortestConnection(Tuple3d p1, Vector3d v1, Tuple3d p2, Vector3d v2, double[] lambda)
lambda[0]
and lambda[1]
such that the line from
p1 + lambda[0] v1
to p2 + lambda[1] v2
is the shortest connection line between these lines.
p1
- a point on the first linev1
- the direction of the first linep2
- a point on the second linev2
- the direction of the second linelambda
- the computed scalars are written into this array
public static double shortestConnection(Tuple3d p1, Vector3d v1, Tuple3f p2, Vector3f v2, double[] lambda)
lambda[0]
and lambda[1]
such that the line from
p1 + lambda[0] v1
to p2 + lambda[1] v2
is the shortest connection line between these lines.
p1
- a point on the first linev1
- the direction of the first linep2
- a point on the second linev2
- the direction of the second linelambda
- the computed scalars are written into this array
public static float shortestConnection(Tuple3f p1, Vector3f v1, Tuple3f p2, Vector3f v2, float[] lambda)
lambda[0]
and lambda[1]
such that the line from
p1 + lambda[0] v1
to p2 + lambda[1] v2
is the shortest connection line between these lines.
p1
- a point on the first linev1
- the direction of the first linep2
- a point on the second linev2
- the direction of the second linelambda
- the computed scalars are written into this array
public static float sin(float x)
x
- an angle, in radians
public static float sin01(float x)
x
is mapped to [0, 2 π], i.e., the angle in radians
is 2 π x
. This method uses a pre-computed
table.
x
- an angle
public static int skySegment(Vector3d rv)
public static float[] toFloatArray(Tuple3d p)
public static float[] toFloatArray(Tuple4d p)
public static float[] toFloatArray(Tuple4f p)
public static void transformPoint(Matrix3d t, Tuple2d p)
public static void transformPoint(Matrix4d t, Tuple3d p)
public static void transformPoint(Matrix4d t, Tuple3d p, Tuple3d out)
public static void transformPoint(Matrix4f t, Tuple3f p)
public static void transformTranspose(Matrix3d t, Tuple3d v)
public static void transformVector(Matrix3d t, Tuple2d v)
public static void transformVector(Matrix4d t, Tuple3d v)
public static void transformVector(Matrix4f t, Tuple3f v)
public static float turbulence(float x, float y, float z, int octaves, float lambda, float omega)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |