cz.cuni.amis.pogamut.base3d.worldview.object
Class Location

java.lang.Object
  extended by cz.cuni.amis.pogamut.base3d.worldview.object.Location
All Implemented Interfaces:
ILocated, java.io.Serializable, java.lang.Cloneable

public class Location
extends java.lang.Object
implements ILocated, java.io.Serializable, java.lang.Cloneable

Location within the world. Location is represented as a point within the world's coordinates.

See Also:
Serialized Form

Nested Class Summary
static class Location.PropertyEditor
          PropertyEditor for class Location.
 
Field Summary
 double x
          X coordinate.
 double y
          Y coordinate.
 double z
          Z coordinate.
 
Constructor Summary
Location()
          Creates location with all values set to zeroes.
Location(double[] d)
          Creates location from array of three doubles.
Location(double x, double y)
          Creates location with specified planar coordinates.
Location(double x, double y, double z)
          Creates location with specified coordinates.
Location(float[] f)
          Creates location from array of three doubles.
Location(Location source)
          Copy constructor
Location(Tuple3d p)
          Creates location from specified 3D point.
 
Method Summary
 Location add(Location l)
          Retreives sum of this location and given location.
static Location add(Location l1, Location l2)
          Retreives sum of two given locations.
static Location add(Location l, Velocity v)
          Adds given velocity to given location.
 Location add(Velocity v)
          Adds given velocity to this location.
 Point3d asPoint3d()
           
 math.geom3d.Point3D asPoint3D()
           
 Vector3d asVector3d()
           
 Location clone()
           
 Location cross(Location b)
          Calculates cross product of this Location and Lcoations b
 double dot(Location b)
          Calculates dot product of this Location and Location b
 double dot2D(Location b)
          Calculates dot product of this Location and Location b in 2D (x,y coord only)
static boolean equal(Location l1, Location l2)
          Tells, whether two given locations equal.
static boolean equal(Location l1, Location l2, double epsilon)
          Tells, whether the distance between coordinates of two given locations is less than or equal to the given epsilon.
 boolean equals(Location v)
          Tells, whether this location equals to given location.
 boolean equals(Location l, double epsilon)
          Tells, whether the distance between coordinates of this location and given location is less than or equal to the given epsilon.
static Location getAverage(java.util.Collection<Location> locations)
          Calculates average of all 'locations'.
 double getDistance(Location l)
          Calculates the distance between this and given location.
static double getDistance(Location l1, Location l2)
          Calculates the distance between two given locations.
 double getDistance2D(Location l)
          Calculates the distance between this and given location (ignoring 'z' coordinate).
static double getDistance2D(Location l1, Location l2)
          Calculates the distance between two given locations (ignoring 'z' coordinate).
 double getDistanceL1(Location l)
          Calculates the Manhattan distance between this and given location.
static double getDistanceL1(Location l1, Location l2)
          Calculates the Manhattan distance between two given locations.
 double getDistanceLinf(Location l)
          Calculates the Chebyshev distance between this and given location.
static double getDistanceLinf(Location l1, Location l2)
          Calculates the Chebyshev distance between two given locations.
 double getDistancePlane(Location l)
          Calculates the distance between this and given location after being projected to the (x,y) plane.
static double getDistancePlane(Location l1, Location l2)
          Calculates the distance between two given locations after being projected to the (x,y) plane.
 double getDistanceSquare(Location l)
          Calculates the square of the distance between this and given location.
static double getDistanceSquare(Location l1, Location l2)
          Calculates the square of the distance between two given locations.
 double getDistanceZ(Location location)
          Returns difference between z-coords (this.z - location.z).
 double getLength()
          Calculates length of Location
 Location getLocation()
          Retreives the location itself to implement ILocated.
 Location getNormalized()
          Normalizes this Location
 Point3d getPoint3d()
          Retreives javax.vecmath.Point3d representation of the location.
 Rotation getQuatLikeRotationSeq(Rotation.Order order)
          WIP not completed yet.
 Rotation getRotation(Rotation.Order order)
          Converts Location into Rotation.
 double getX()
          X coordinate.
 double getY()
          Y coordinate.
 double getZ()
          Z coordinate.
 Location interpolate(Location l, double d)
          Lineary interpolates between this location and given location.
static Location interpolate(Location l1, Location l2, double d)
          Linearly interpolates between two given locations.
 Location invert()
          Calculates inverse Location
 Location mul(Matrix3d matrix)
          Projects this Location (vector) using matrix from parameter
 Location scale(double d)
          Scales values of all three coordinates by given multiplier.
 Location setTo(double x, double y, double z)
          Set content of this location from passed data.
 Location setTo(Location l)
          Set content of this location from passed tocation.
 Location sub(Location l)
          Retreives subtraction of given location from this location.
static Location sub(Location l1, Location l2)
          Retreives subtraction of two given locations.
static Location sub(Location l, Velocity v)
          Subtracts given velocity from given location.
 Location sub(Velocity v)
          Subtracts given velocity from this location.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
X coordinate.


y

public double y
Y coordinate.


z

public double z
Z coordinate.

Constructor Detail

Location

public Location()
Creates location with all values set to zeroes.


Location

public Location(double x,
                double y,
                double z)
Creates location with specified coordinates.

Parameters:
x - X coordinate.
y - Y coordinate.
z - Z coordinate.

Location

public Location(double x,
                double y)
Creates location with specified planar coordinates. Sets z to zero.

Parameters:
x - X coordinate.
y - Y coordinate.

Location

public Location(Location source)
Copy constructor

Parameters:
source - Location to copy

Location

public Location(double[] d)
Creates location from array of three doubles. Sets x = d[0], y = d[1] and z = d[2].

Parameters:
d - Array of doubles to be used for creation.

Location

public Location(float[] f)
Creates location from array of three doubles. Sets x = f[0], y = f[1] and z = f[2].

Parameters:
f - Array of to be used for creation.

Location

public Location(Tuple3d p)
Creates location from specified 3D point.

Parameters:
p - Point in space to be used for creation.
Method Detail

clone

public Location clone()
Overrides:
clone in class java.lang.Object

asVector3d

public Vector3d asVector3d()

asPoint3d

public Point3d asPoint3d()

asPoint3D

public math.geom3d.Point3D asPoint3D()

getX

public double getX()
X coordinate.

Returns:
X coordinate.

getY

public double getY()
Y coordinate.

Returns:
Y coordinate.

getZ

public double getZ()
Z coordinate.

Returns:
Z coordinate.

add

public Location add(Location l)
Retreives sum of this location and given location.

Parameters:
l - Location to be added to this location.
Returns:
Sum of the two locations.

add

public static Location add(Location l1,
                           Location l2)
Retreives sum of two given locations.

Parameters:
l1 - First location to be summed.
l2 - Second location to be summed.
Returns:
Sum of the two locations.

sub

public Location sub(Location l)
Retreives subtraction of given location from this location.

Parameters:
l - Location to be subtracted.
Returns:
Subtraction of the two locations.

sub

public static Location sub(Location l1,
                           Location l2)
Retreives subtraction of two given locations.

Parameters:
l1 - Location to be subtracted from.
l2 - Location to be subtracted.
Returns:
Subtraction of the two locations.

add

public Location add(Velocity v)
Adds given velocity to this location.

Parameters:
v - Velocity to be added to this location.
Returns:
Sum of the location and velocity.

add

public static Location add(Location l,
                           Velocity v)
Adds given velocity to given location.

Parameters:
l - Location to be summed.
v - Velocity to be summed.
Returns:
Sum of the location and velocity.

sub

public Location sub(Velocity v)
Subtracts given velocity from this location.

Parameters:
v - Velocity to be subtracted.
Returns:
Subtraction of the velocity from the location.

sub

public static Location sub(Location l,
                           Velocity v)
Subtracts given velocity from given location.

Parameters:
l - Location to be subtracted from.
v - Velocity to be subtracted.
Returns:
Subtraction of the velocity from the location.

scale

public Location scale(double d)
Scales values of all three coordinates by given multiplier.

Parameters:
d - Scaling multiplier.
Returns:
Location with all three coordinates negated.

interpolate

public Location interpolate(Location l,
                            double d)
Lineary interpolates between this location and given location.

Parameters:
l - Location to be interpolated to.
d - Interpolation parameter.
Returns:
Linear interpolation between the two locations.

interpolate

public static Location interpolate(Location l1,
                                   Location l2,
                                   double d)
Linearly interpolates between two given locations.

Parameters:
l1 - Location to be interpolated from.
l2 - Location to be interpolated to.
d - Interpolation parameter.
Returns:
Linear interpolation between the two locations.

equals

public boolean equals(Location v)
Tells, whether this location equals to given location.

Parameters:
v - Location to be compared with.
Returns:
True, if the locations have the same values of all three corresponding coordinates.

equal

public static boolean equal(Location l1,
                            Location l2)
Tells, whether two given locations equal.

Parameters:
l1 - First location to comapre.
l2 - Second location to comapre.
Returns:
True, if the locations have the same values of all three corresponding coordinates.

equals

public boolean equals(Location l,
                      double epsilon)
Tells, whether the distance between coordinates of this location and given location is less than or equal to the given epsilon.

Parameters:
l - Location to comapre with.
epsilon - Epsilon to compare with.
Returns:
True, if the distance between the locations is less than the epsilon, false otherwise.

equal

public static boolean equal(Location l1,
                            Location l2,
                            double epsilon)
Tells, whether the distance between coordinates of two given locations is less than or equal to the given epsilon.

Parameters:
l1 - First location to comapre.
l2 - Second location to comapre.
epsilon - Epsilon to compare with.
Returns:
True, if the distance between the locations is less than the epsilon, false otherwise.

getAverage

public static Location getAverage(java.util.Collection<Location> locations)
Calculates average of all 'locations'. If locations.size() == 0, returns null.

Parameters:
locations -
Returns:
average location

getDistance

public double getDistance(Location l)
Calculates the distance between this and given location.

Parameters:
l - Location to be calculated the distance to.
Returns:
Euclidean distance between the two locations.

getDistance2D

public double getDistance2D(Location l)
Calculates the distance between this and given location (ignoring 'z' coordinate).

Parameters:
l - Location to be calculated the distance to.
Returns:
Euclidean distance between the two locations.

getDistance

public static double getDistance(Location l1,
                                 Location l2)
Calculates the distance between two given locations.

Parameters:
l1 - Location to be calculated the distance from.
l2 - Location to be calculated the distance to.
Returns:
Euclidean distance between the two locations.

getDistanceZ

public double getDistanceZ(Location location)
Returns difference between z-coords (this.z - location.z).

Parameters:
location -
Returns:
z-difference

getDistance2D

public static double getDistance2D(Location l1,
                                   Location l2)
Calculates the distance between two given locations (ignoring 'z' coordinate).

Parameters:
l1 - Location to be calculated the distance from.
l2 - Location to be calculated the distance to.
Returns:
Euclidean distance between the two locations.

getDistanceSquare

public double getDistanceSquare(Location l)
Calculates the square of the distance between this and given location.

Parameters:
l - Location to be calculated the distance to.
Returns:
Square of the euclidean distance between the two locations.

getDistanceSquare

public static double getDistanceSquare(Location l1,
                                       Location l2)
Calculates the square of the distance between two given locations.

Parameters:
l1 - Location to be calculated the distance from.
l2 - Location to be calculated the distance to.
Returns:
Square of the euclidean distance between the two locations.

getDistanceL1

public double getDistanceL1(Location l)
Calculates the Manhattan distance between this and given location.

Parameters:
l - Location to be calculated the distance to.
Returns:
Manhattan (i.e. 1-norm) distance between the two locations.

getDistanceL1

public static double getDistanceL1(Location l1,
                                   Location l2)
Calculates the Manhattan distance between two given locations.

Parameters:
l1 - Location to be calculated the distance from.
l2 - Location to be calculated the distance to.
Returns:
Manhattan (i.e. 1-norm) distance between the two locations.

getDistanceLinf

public double getDistanceLinf(Location l)
Calculates the Chebyshev distance between this and given location.

Parameters:
l - Location to be calculated the distance to.
Returns:
Chebyshev (i.e. infinity-norm) distance between the two locations.

getDistanceLinf

public static double getDistanceLinf(Location l1,
                                     Location l2)
Calculates the Chebyshev distance between two given locations.

Parameters:
l1 - Location to be calculated the distance from.
l2 - Location to be calculated the distance to.
Returns:
Chebyshev (i.e. infinity-norm) distance between the two locations.

getDistancePlane

public double getDistancePlane(Location l)
Calculates the distance between this and given location after being projected to the (x,y) plane.

Parameters:
l - Location to be calculated the distance to.
Returns:
Plane-projected distance between the two locations.

getDistancePlane

public static double getDistancePlane(Location l1,
                                      Location l2)
Calculates the distance between two given locations after being projected to the (x,y) plane.

Parameters:
l1 - Location to be calculated the distance from.
l2 - Location to be calculated the distance to.
Returns:
Plane-projected distance between the two locations.

getLocation

public Location getLocation()
Retreives the location itself to implement ILocated.

Specified by:
getLocation in interface ILocated
Returns:
The location itself (note: does not create a copy).

getPoint3d

public Point3d getPoint3d()
Retreives javax.vecmath.Point3d representation of the location.

Returns:
javax.vecmath.Point3d representation with x, y and z values set.

dot

public double dot(Location b)
Calculates dot product of this Location and Location b

Parameters:
b - Location to dot with
Returns:
dot product of this and b

dot2D

public double dot2D(Location b)
Calculates dot product of this Location and Location b in 2D (x,y coord only)

Parameters:
b - Location to dot with
Returns:
dot product of this and b

cross

public Location cross(Location b)
Calculates cross product of this Location and Lcoations b

Parameters:
b - Location to cross with
Returns:
cross product of this and b

getRotation

public Rotation getRotation(Rotation.Order order)
Converts Location into Rotation. Since location is only a single vector, roll is ommited.

Parameters:
order - tells resulting rotation, which rotation order should it represent
Returns:
resulting rotation

getQuatLikeRotationSeq

public Rotation getQuatLikeRotationSeq(Rotation.Order order)
WIP not completed yet. Use only in case roll yaw pitch order is used. Converts this location into rotation required to be applied on (1,0,0) in order achieve this location. Difference from getRotation is that in this case, quaternion like rotation chaining is achieved. That means that if you take rotation (x, y, z) then result would be same as applying rotation (x, 0, 0) on (1, 0, 0) - identity - then (0, y, 0) on the result, but like it was identity. Then again (0, 0, z) on the result like it was identity. Thus it works in similar vein as quaternion multiplication.

Parameters:
order -
Returns:

getNormalized

public Location getNormalized()
Normalizes this Location

Returns:
normalized

getLength

public double getLength()
Calculates length of Location

Returns:
length

mul

public Location mul(Matrix3d matrix)
Projects this Location (vector) using matrix from parameter

Parameters:
matrix - projection matrix
Returns:
resulting Location

invert

public Location invert()
Calculates inverse Location

Returns:
new inverted Location

setTo

public Location setTo(Location l)
Set content of this location from passed tocation.

Returns:
this with newly set value

setTo

public Location setTo(double x,
                      double y,
                      double z)
Set content of this location from passed data.

Returns:
this with newly set value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object