Packageorg.un.flex.utils.geom
Classpublic class BaseModel
ImplementsIModel
SubclassesPoincareModel

This class provides a skeleton implementation of the Model interface to minimize the effort to implement a new model. It provides implementation of isometry providing methods such as those for rotation and translation.
Other methods for computing distance, projection, and gradient are no-ops.
For a given model, it is usually more efficient to implement the isometry providing methods directly.
The implementation is a rewrite of Jens Kanschik's Hypergraph implementation in Java. However, apart from the general idea and some variable names, this code improves on hypergraph and also implements additional functionality. Copyright (C) 2003 Jens Kanschik, mail : jensKanschik



Protected Properties
 PropertyDefined by
  t_isom1 : IIsometry
BaseModel
  t_isom2 : IIsometry
BaseModel
  t_z1 : IPoint
BaseModel
Public Methods
 MethodDefined by
  
dist(z:IPoint):Number
Calculates the distance from z to the origin.
BaseModel
  
dist2(z:IPoint):Number
Computes the squared distance from z to the origin.
BaseModel
  
Computes the gradient at basePoint of the distance functions to z, i.e.
BaseModel
  
distanceGradientV(base:IPoint, z:IPoint, gradient:IVector):void
Computes the gradient at basePoint of the distance functions to z, i.e.
BaseModel
  
distP(mp1:IPoint, mp2:IPoint):Number
Computes the distance between two points.
BaseModel
  
distP2(mp1:IPoint, mp2:IPoint):Number
Computes the squared distance between two points.
BaseModel
  
exp(v:IVector, length:Number):IPoint
Calculates the exponent of the vector maintaining the same direction as the vector
BaseModel
  
getAngle(p:IPoint, z1:IPoint, z2:IPoint):Number
Returns the angle between the line segments starting at p and ending in z1 and z2 respectively.
If the model is orientated, the angle may have a sign, but this is not required.
BaseModel
  
Returns a "default" vector at the origin.
In most models, there is no special vector, but it is very convenient to have such a default vector to start with.
This vector is always located at the origin, is always normalized (i.e.
BaseModel
  
getDistance(p:IPoint, z1:IPoint, z2:IPoint, cutoff1:Boolean, cutoff2:Boolean):Number
Returns the distance of p to the line, ray or line segment from z1 to z2.
The parameters cutoff1 and cutoff2 define whether the whole line should be considered or only parts.
BaseModel
  
Returns the identity transformation.
BaseModel
  
FOLLOWING METHODS MUST BE IMPLEMENTED BY SUBCLASSES
BaseModel
  
getProjection(p:IPoint, z1:IPoint, z2:IPoint, cutoff1:Boolean, cutoff2:Boolean):IPoint
Returns the projection of point p on the line defined by the points z1 and z2.
BaseModel
  
getRotation(alpha:Number):IIsometry
Returns a rotation of alpha at the origin.
BaseModel
  
getRotationP(mp:IPoint, alpha:Number):IIsometry
Returns a rotation of alpha at the point p.
BaseModel
  
Calculates the translation (isometry) to a given point p.
BaseModel
  
Calculates the translation (isometry) from a given point p2 to a destination point p1.
BaseModel
  
getTranslationIPPR(isom:IIsometry, mp1:IPoint, mp2:IPoint, t:Number):void
Calculate the translation of a given point to a destination point in a given number of steps
BaseModel
  
getTranslationIPR(isom:IIsometry, mp1:IPoint, r:Number):void
Calculates the r-th root (isometry) of the translation to a given point.
BaseModel
  
getTranslationIVR(isom:IIsometry, vector:IVector, t:Number):void
Calculates the translation for the base of the given vector in a specific direction
BaseModel
  
Returns the translation to a given point z.
BaseModel
  
Translate a point to another point
BaseModel
  
Translate a given point to a destination point in a given number of steps
BaseModel
  
Returns the r-th root (isometry) of the translation to a given point.
BaseModel
  
getTranslationVR(vector:IVector, t:Number):IIsometry
Returns the translation for the base of the given vector in a specific direction
BaseModel
  
length(v:IVector):Number
Returns the length of the vector.
BaseModel
  
length2(v:IVector):Number
Returns the squared length of the vector.
BaseModel
  
product(v1:IVector, v2:IVector):Number
Returns the scalar product of the two vectors.
They have to have the same base point, otherwise, a computation is not possible.
BaseModel
Property detail
t_isom1property
protected var t_isom1:IIsometry
t_isom2property 
protected var t_isom2:IIsometry
t_z1property 
protected var t_z1:IPoint
Method detail
dist()method
public function dist(z:IPoint):Number

Calculates the distance from z to the origin.

Parameters
z:IPoint — A point in the model.

Returns
Number — The distance from z to the origin.
dist2()method 
public function dist2(z:IPoint):Number

Computes the squared distance from z to the origin.

Parameters
z:IPoint — A point in the model.

Returns
Number — The squared distance from z to the origin.
distanceGradient()method 
public function distanceGradient(base:IPoint, z:IPoint):IVector

Computes the gradient at basePoint of the distance functions to z, i.e.

         grad           d(z)
             |basepoint
   
or "grad_{|basepoint}d(\cdot,z)" in tex.

Parameters
base:IPoint — The base of the gradient
 
z:IPoint — The end point of the gradient

Returns
IVector — the resulting gradient vector
distanceGradientV()method 
public function distanceGradientV(base:IPoint, z:IPoint, gradient:IVector):void

Computes the gradient at basePoint of the distance functions to z, i.e.

         grad           d(z)
             |basepoint
   
or "grad_{|basepoint}d(\cdot,z)" in tex.

Parameters
base:IPoint — The base of the gradient
 
z:IPoint — The end point of the gradient
 
gradient:IVector — the resulting gradient vector
distP()method 
public function distP(mp1:IPoint, mp2:IPoint):Number

Computes the distance between two points.

Parameters
mp1:IPoint — A point in the model.
 
mp2:IPoint — A point in the model.

Returns
Number — The distance of the two points.
distP2()method 
public function distP2(mp1:IPoint, mp2:IPoint):Number

Computes the squared distance between two points.

Parameters
mp1:IPoint — A point in the model.
 
mp2:IPoint — A point in the model.

Returns
Number — The squared distance of the two points.
exp()method 
public function exp(v:IVector, length:Number):IPoint

Calculates the exponent of the vector maintaining the same direction as the vector

Parameters
v:IVector — the vector to use
 
length:Number — the new length

Returns
IPoint — new vector length as a complex number
getAngle()method 
public function getAngle(p:IPoint, z1:IPoint, z2:IPoint):Number

Returns the angle between the line segments starting at p and ending in z1 and z2 respectively.
If the model is orientated, the angle may have a sign, but this is not required.

Parameters
p:IPoint — The commong starting point of the two segments.
 
z1:IPoint — The end point of the first line segment.
 
z2:IPoint — The end point of the first line segment.

Returns
Number — The angle of the hinge defined by the three parameters.
getDefaultVector()method 
public function getDefaultVector():IVector

Returns a "default" vector at the origin.
In most models, there is no special vector, but it is very convenient to have such a default vector to start with.
This vector is always located at the origin, is always normalized (i.e. has length 1) and it always has to be the same.

Returns
IVector — A normalized vector at the origin.
getDistance()method 
public function getDistance(p:IPoint, z1:IPoint, z2:IPoint, cutoff1:Boolean, cutoff2:Boolean):Number

Returns the distance of p to the line, ray or line segment from z1 to z2.
The parameters cutoff1 and cutoff2 define whether the whole line should be considered or only parts.

If the geometry of the model allows to give the distance a sign using a well defined orientation, (e.g. for most two dimensional models) it should do so, but it is not required.

Parameters
p:IPoint — The point from which the distance is computed.
 
z1:IPoint — The starting point of the line segment.
 
z2:IPoint — The end point of the line segment.
 
cutoff1:Boolean — If true, the line is cut off at z1.
 
cutoff2:Boolean — If true, the line is cut off at z2.

Returns
Number — The distance from p to the line, ray or linesegment defined by the other parameters.
getIdentity()method 
public function getIdentity():IIsometry

Returns the identity transformation.

Returns
IIsometry — The identity transformation.
getOrigin()method 
public function getOrigin():IPoint

FOLLOWING METHODS MUST BE IMPLEMENTED BY SUBCLASSES

Returns
IPoint
getProjection()method 
public function getProjection(p:IPoint, z1:IPoint, z2:IPoint, cutoff1:Boolean, cutoff2:Boolean):IPoint

Returns the projection of point p on the line defined by the points z1 and z2.

Parameters
p:IPoint — The point to project.
 
z1:IPoint — A point on the line on which to project.
 
z2:IPoint — A point on the line on which to project.
 
cutoff1:Boolean
 
cutoff2:Boolean

Returns
IPoint — The projection.
getRotation()method 
public function getRotation(alpha:Number):IIsometry

Returns a rotation of alpha at the origin. Only well defined in 2D, oriented models.

Parameters
alpha:Number — The angle of the rotation.

Returns
IIsometry — The rotation at the origin with angle alpha.
getRotationP()method 
public function getRotationP(mp:IPoint, alpha:Number):IIsometry

Returns a rotation of alpha at the point p. Only well defined in 2D, oriented models.

Parameters
mp:IPoint — The basepoint of the rotation.
 
alpha:Number — The angle of the rotation.

Returns
IIsometry — The rotation at p with angle alpha.
getTranslationIP()method 
public function getTranslationIP(isom:IIsometry, mp1:IPoint):void

Calculates the translation (isometry) to a given point p.

Parameters
isom:IIsometry — the resulting isometry
 
mp1:IPoint — the given point
getTranslationIPP()method 
public function getTranslationIPP(isom:IIsometry, mp1:IPoint, mp2:IPoint):void

Calculates the translation (isometry) from a given point p2 to a destination point p1.

Parameters
isom:IIsometry — the resulting isometry
 
mp1:IPoint — the destination point
 
mp2:IPoint — the given point
getTranslationIPPR()method 
public function getTranslationIPPR(isom:IIsometry, mp1:IPoint, mp2:IPoint, t:Number):void

Calculate the translation of a given point to a destination point in a given number of steps

Parameters
isom:IIsometry — the resulting isometry
 
mp1:IPoint — The destination point
 
mp2:IPoint — The given point
 
t:Number — Number of steps (roots)
getTranslationIPR()method 
public function getTranslationIPR(isom:IIsometry, mp1:IPoint, r:Number):void

Calculates the r-th root (isometry) of the translation to a given point.

Parameters
isom:IIsometry — the resulting isometry
 
mp1:IPoint — the given point
 
r:Number — the root.
getTranslationIVR()method 
public function getTranslationIVR(isom:IIsometry, vector:IVector, t:Number):void

Calculates the translation for the base of the given vector in a specific direction

Parameters
isom:IIsometry — the resulting isometry
 
vector:IVector — the vector to move
 
t:Number — distance to move
getTranslationP()method 
public function getTranslationP(mp1:IPoint):IIsometry

Returns the translation to a given point z.

Parameters
mp1:IPoint — the given point.

Returns
IIsometry
getTranslationPP()method 
public function getTranslationPP(mp1:IPoint, mp2:IPoint):IIsometry

Translate a point to another point

Parameters
mp1:IPoint — The destination point
 
mp2:IPoint — The point to be moved.

Returns
IIsometry
getTranslationPPR()method 
public function getTranslationPPR(mp1:IPoint, mp2:IPoint, t:Number):IIsometry

Translate a given point to a destination point in a given number of steps

Parameters
mp1:IPoint — The destination point
 
mp2:IPoint — The given point
 
t:Number — Number of steps (roots)

Returns
IIsometry
getTranslationPR()method 
public function getTranslationPR(mp:IPoint, t:Number):IIsometry

Returns the r-th root (isometry) of the translation to a given point.

Parameters
mp:IPoint — the given point.
 
t:Number — the root.

Returns
IIsometry
getTranslationVR()method 
public function getTranslationVR(vector:IVector, t:Number):IIsometry

Returns the translation for the base of the given vector in a specific direction

Parameters
vector:IVector — the vector to move
 
t:Number — distance to move

Returns
IIsometry
length()method 
public function length(v:IVector):Number

Returns the length of the vector.

Parameters
v:IVector — A vector in the tangent space of the model.

Returns
Number — The length of the vector.
length2()method 
public function length2(v:IVector):Number

Returns the squared length of the vector.

Parameters
v:IVector — A vector in the tangent space of the model.

Returns
Number — The squared length of the vector.
product()method 
public function product(v1:IVector, v2:IVector):Number

Returns the scalar product of the two vectors.
They have to have the same base point, otherwise, a computation is not possible. NaN is returned in this situation.

Parameters
v1:IVector — A vector in the tangentspace of the model.
 
v2:IVector — A vector in the tangentspace of the model.

Returns
Number — The scalar product of both vectors.