Class Sphere
public final class Sphere
extends java.lang.Object
A sphere is only defined by its radius. Unlike Matrix, Vector and Complex it is a rather stiff object. You cannot "calculate" a lot, but the class Sphere offers a small library of spherical operations that eases the handling of matrices, vectors and complex numbers.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Sphere(double r)
Creates a sphere with the specified radius. -
Method Summary
Modifier and Type Method Description Matrix
base(Vector v)
Creates an orthonormal basis from a given vector.Matrix
base(Vector v, double alpha)
Creates an orthonormal basis from a given vector and a turn angle.double
diff(Vector a, Vector b)
Returns the distance between two vectors on the sphere.boolean
equals(java.lang.Object S)
Compares with a spherestatic Vector
euler(Matrix M)
Creates the Euler vector from a matrix.static Matrix
euler(Vector v)
Creates the matrix from an Euler vector.int
hashCode()
Returns the hash code.java.lang.String
toString()
String representation.Vector
warp(Complex c)
Transforms a plane position into a spherical position.Matrix
warp(Complex c, double alpha)
Transforms a plane position into a spherical position.Vector
warp(Matrix M)
Transforms a spherical position into a plane position.Complex
warp(Vector v)
Transforms a spherical position into a plane position.
-
Field Details
-
Constructor Details
-
Sphere
public Sphere(double r)Creates a sphere with the specified radius.- Parameters:
r
- Radius
-
-
Method Details
-
hashCode
public int hashCode()Returns the hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code
-
toString
public java.lang.String toString()String representation.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string
-
equals
public boolean equals(java.lang.Object S)Compares with a sphere- Overrides:
equals
in classjava.lang.Object
- Parameters:
S
- sphere- Returns:
- the equality
-
diff
Returns the distance between two vectors on the sphere.If R is the sphere radius, and if a, b != 0 are the two vectors, this function will compute:
R * acos(< a, b > / |a||b|)
- Parameters:
a
- vectorb
- vector- Returns:
- the distance
-
base
Creates an orthonormal basis from a given vector.If v != 0 is the vector and (a,b,c) the orthonormal basis, there is:
- c = v / |v|
- b = z x c [ z = (0,0,1) ]
- a = b x c
- Parameters:
v
- vector- Returns:
- the basis
-
base
Creates an orthonormal basis from a given vector and a turn angle.The orthonormal basis (a,b,c) is first generated from the vector, then turned by the turn angle around its c-axis.
- Parameters:
v
- vectoralpha
- angle- Returns:
- the basis
-
warp
Transforms a plane position into a spherical position.- Parameters:
c
- complex number- Returns:
- the spherical vector
-
warp
Transforms a plane position into a spherical position.The plane visual angles are parametrized in a way that angles of value 0 point along the ray from the origin to the position.
- Parameters:
c
- complex numberalpha
- visual angle- Returns:
- the spherical matrix
-
warp
Transforms a spherical position into a plane position.- Parameters:
v
- spherical vector- Returns:
- the complex number
-
warp
Transforms a spherical position into a plane position.The plane visual angles are parametrized in a way that angles of value 0 point along the ray from the origin to the position.
For practical reasons, the returned values position and visual angle are packed in a Vector object and should be decomposed at once by a programming code as follows:
Vector v = Sphere.warp(M); // "(c,a) = Sphere.warp(M);" Complex c = new Complex(cf.x,v.y); // c = position double a = v.z; // a = visual angle
- Parameters:
M
- spherical matrix- Returns:
- the complex number and the visual angle as Vector object
-
euler
Creates the matrix from an Euler vector.- Parameters:
v
- Euler vector- Returns:
- the matrix
-
euler
Creates the Euler vector from a matrix.- Parameters:
M
- matrix- Returns:
- the Euler vector
-