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 var t_isom1:IIsometry
protected var t_isom2:IIsometry
protected var t_z1:IPoint
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.
|
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.
|
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
|
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
|
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.
|
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.
|
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
|
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.
|
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.
|
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.
getDistance(p, z1, z2, true, true)
returns the distance to the line segment.
getDistance(p, z1, z2, false, true)
returns the distance to the ray starting in z1.
getDistance(p, z1, z2, false, false)
returns the distance to the whole (infinite) line.
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.
|
public function getIdentity():IIsometry
Returns the identity transformation.
Returns
public function getOrigin():IPoint FOLLOWING METHODS MUST BE IMPLEMENTED BY SUBCLASSES
Returns
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
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.
|
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.
|
public function getTranslationIP(isom:IIsometry, mp1:IPoint):void
Calculates the translation (isometry) to a given point p.
Parameters
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
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)
|
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.
|
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
|
public function getTranslationP(mp1:IPoint):IIsometry
Returns the translation to a given point z.
Parameters
Returns
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
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
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
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
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.
|
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.
|
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.
|