backend
Class SpheriosityUtils

java.lang.Object
  extended by backend.SpheriosityUtils

public class SpheriosityUtils
extends java.lang.Object

SpheriosityUtils is a set of helper functions that get common values for things that might be useful to know for our application. Most of these utils will be for computing geometric things that are guided to help the user


Constructor Summary
SpheriosityUtils()
           
 
Method Summary
static boolean angleCheck(javax.vecmath.Vector3f rotationAxis, javax.vecmath.Point3f tangentPoint, javax.vecmath.Point3f userPoint)
          angleCheck will tell you if the point passed in will rotate "as expected" or if it needs to be rotated in the opposite direction.
static void appendErrorMessageToFile(java.lang.String message, java.lang.String filename)
          appendErrorMessageToFile is used for making error message files
static void enablePicking(javax.media.j3d.Node node)
          enablePicking allows for accurate picking of objects.
static float getAngle(javax.vecmath.Point3f firstPoint, javax.vecmath.Point3f middlePoint, javax.vecmath.Point3f finalPoint)
          getAngle returns the angle between three points.
static javax.vecmath.Vector3f getAxisOfRotation(javax.vecmath.Tuple3f firstVec, javax.vecmath.Tuple3f secondVec)
          getAxisOfRotation will return the axis of rotation in the spherical sense if given two vectors which were created as going from the center of the sphere to an outside point.
static java.lang.String getDate()
          getDate will return the current date and time in a simple format of yyyy-mm-dd hh:mm.
static java.lang.String getFormattedDouble(double formatMe)
          getForattedDouble returns a formatted version of the double passed to it
static float getGreatCircleLength(float sphereRadius)
          greatCircleLength will return the length of a great circle on a sphere of given radius
static float getLongLineLength(javax.vecmath.Point3f firstPoint, javax.vecmath.Point3f secondPoint, float sphereRadius)
          getLongLineLength gets the long length of a line on a sphere.
static float getShortLineLength(javax.vecmath.Point3f firstPoint, javax.vecmath.Point3f secondPoint, float sphereRadius)
          shortLineLength will return the shortest distance between two points on a sphere.
static java.lang.String getStackTraceData(java.lang.Exception e)
          getStackTraceData will return the stack trace as a String
static float getTriangleArea(javax.vecmath.Point3f firstPoint, javax.vecmath.Point3f secondPoint, javax.vecmath.Point3f thirdPoint, float sphereRad)
          getTriangleArea will return the area of a spherical triangle.
static void rotatePoint(javax.vecmath.Vector3f axisOfRotation, javax.vecmath.Point3f rotateMe, float angle)
          rotatePoint will rotate a given point a given angle on a given axis of rotation.
static javax.vecmath.Tuple3f tupleSubtract(javax.vecmath.Tuple3f minuend, javax.vecmath.Tuple3f subtrahend)
          tupleSubtract will subtract the second tuple from the first and return the result.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpheriosityUtils

public SpheriosityUtils()
Method Detail

getShortLineLength

public static float getShortLineLength(javax.vecmath.Point3f firstPoint,
                                       javax.vecmath.Point3f secondPoint,
                                       float sphereRadius)
shortLineLength will return the shortest distance between two points on a sphere. It assumes that the sphere in question is centered about the origin. While the code could be changed to represent an arbitray sphere for time reasons we will leave that assumption in place and change it should be allow for different placement of a sphere

Parameters:
firstPoint - Is the first point used in defining our line
secondPoint - Is the second point used in defining our line
sphereRadius - Is the radius of the sphere we are working with
Returns:
The length of the line segment defined by the two points

getGreatCircleLength

public static float getGreatCircleLength(float sphereRadius)
greatCircleLength will return the length of a great circle on a sphere of given radius

Parameters:
sphereRadius - is the radius of the sphere
Returns:
The length of the line that is the great circle

getLongLineLength

public static float getLongLineLength(javax.vecmath.Point3f firstPoint,
                                      javax.vecmath.Point3f secondPoint,
                                      float sphereRadius)
getLongLineLength gets the long length of a line on a sphere.

Parameters:
firstPoint - The first point of the line in question
secondPoint - The second point to define the line with
sphereRadius - The radius of the sphere we are working with
Returns:
The length of a the long line connecting two points.

getAngle

public static float getAngle(javax.vecmath.Point3f firstPoint,
                             javax.vecmath.Point3f middlePoint,
                             javax.vecmath.Point3f finalPoint)
getAngle returns the angle between three points. Be careful not to send this function duplicate points it will not like you and it may dump your entire filesystem out to /dev/null...

Parameters:
firstPoint - is the first point of the angle
middlePoint - is the middle point of the angle
finalPoint - is the last point that defines the angle
Returns:
The angle measure between the three points

getTriangleArea

public static float getTriangleArea(javax.vecmath.Point3f firstPoint,
                                    javax.vecmath.Point3f secondPoint,
                                    javax.vecmath.Point3f thirdPoint,
                                    float sphereRad)
getTriangleArea will return the area of a spherical triangle. It assumes the three points are part of a "small triangle" meaning the triangle fits on one hemisphere and does not have antipidol points. Additionally it assumes none of the points are duplicates.

Parameters:
firstPoint - The first point of the triangle
secondPoint - The second point of the triangle
thirdPoint - The third point of the triangle
sphereRad - The radius of the sphere the triangles are on
Returns:
The area of the triangle defined by the three points

enablePicking

public static void enablePicking(javax.media.j3d.Node node)
enablePicking allows for accurate picking of objects. A huge thanks to: http://www.java3d.org/ for this code segment because I had no idea how to make this work It may throw exceptions, but I have found them safe to ignore for the time being

Parameters:
node - is the node to enable picking for

getFormattedDouble

public static java.lang.String getFormattedDouble(double formatMe)
getForattedDouble returns a formatted version of the double passed to it

Parameters:
formatMe - is the double to format
Returns:
The double to the correct amount of decimal places

tupleSubtract

public static javax.vecmath.Tuple3f tupleSubtract(javax.vecmath.Tuple3f minuend,
                                                  javax.vecmath.Tuple3f subtrahend)
tupleSubtract will subtract the second tuple from the first and return the result. It does this component wise so the x component of the first tuple from the x component of the second tuple, etc.

Parameters:
minuend - left hand side of the minus sign
subtrahend - right hand side of the minus sign
Returns:
a tuple3f with the substraction

getAxisOfRotation

public static javax.vecmath.Vector3f getAxisOfRotation(javax.vecmath.Tuple3f firstVec,
                                                       javax.vecmath.Tuple3f secondVec)
getAxisOfRotation will return the axis of rotation in the spherical sense if given two vectors which were created as going from the center of the sphere to an outside point. Please note that the function actually takes two Tuple3fs this is a convinence for the programmer because sometimes making the correct Vector is merely a matter of using the point. So to save the programmer from doing new Vector(...) we have made this accept Tuple3fs. This is not an excuse for laziness and just thinking you can pass this in any old values and have the result be meaningful. Please make sure what you send it would actually end up being the correct vectors! Also please note that antipodal points have undefined behavior so be careful calling this function

Parameters:
firstVec - is the first vector of the line
secondPoint - is the second vector of the line
Returns:
a Vector3f which properly represents the axis of rotation.

rotatePoint

public static void rotatePoint(javax.vecmath.Vector3f axisOfRotation,
                               javax.vecmath.Point3f rotateMe,
                               float angle)
rotatePoint will rotate a given point a given angle on a given axis of rotation. This function will change the actual value of the point passed to it so please make sure you did not need the current values in the point you passed it. The point is rotated counter-clockwise with respect to the axis of rotation

Parameters:
axisOfRotation - the axis to use to rotate the given point
rotateMe - is the point to rotate. WARNING the values stored here will be changed to reflect the rotation!
angle - the amount of rotate

angleCheck

public static boolean angleCheck(javax.vecmath.Vector3f rotationAxis,
                                 javax.vecmath.Point3f tangentPoint,
                                 javax.vecmath.Point3f userPoint)
angleCheck will tell you if the point passed in will rotate "as expected" or if it needs to be rotated in the opposite direction. The check approximates a tangent vector and then takes the dot product of that vector with the point from the user.

Parameters:
rotationAxis - is the axis of rotation to make the tangent vector with
tangentPoint - is the point to make a tangent vector with
userPoint - is the point we want to rotate towards
Returns:
true if the normal rotation is sufficient false if it should be the opposite direction

getStackTraceData

public static java.lang.String getStackTraceData(java.lang.Exception e)
getStackTraceData will return the stack trace as a String

Parameters:
e - is the exception to get a stack trace from
Returns:
The stack trace as a String

getDate

public static java.lang.String getDate()
getDate will return the current date and time in a simple format of yyyy-mm-dd hh:mm.

Returns:
A string with the current date and time Special thanks to: http://www.rgagnon.com/javadetails/java-0106.html for this little snippet of code

appendErrorMessageToFile

public static void appendErrorMessageToFile(java.lang.String message,
                                            java.lang.String filename)
appendErrorMessageToFile is used for making error message files

Parameters:
message - is the message to write to the file
filename - is the file to write the message to