AxisPlaneConstraint Class Reference

An abstract class for Frame constraints that use an axis or a plane. More...

#include <constraint.h>

Inherits Constraint.

Inherited by CameraConstraint, LocalConstraint, and WorldConstraint.

List of all members.

Translation constraints

virtual void constrainTranslation (Vec &, Frame *const )=0
void setTranslationConstraint (const Type t, const Vec &dir)
void setTranslationConstraint (const Type t, const float x, const float y, const float z)
void setTranslationConstraintType (const Type t)
void setTranslationConstraintDir (const Vec &dir)
Type translationConstraintType () const
void getTranslationConstraintDir (float &x, float &y, float &z) const
Vec translationConstraintDir () const

Rotation constraints

virtual void constrainRotation (Quaternion &, Frame *const )=0
void setRotationConstraint (const Type t, const Vec &dir)
void setRotationConstraint (const Type t, const float x, const float y, const float z)
void setRotationConstraintType (const Type t)
void setRotationConstraintDir (const Vec &dir)
Type rotationConstraintType () const
void getRotationConstraintDir (float &x, float &y, float &z) const
Vec rotationConstraintDir () const

Public Types

enum  Type { FREE, PLANE, AXIS, FORBIDDEN }

Public Member Functions

 AxisPlaneConstraint ()
virtual ~AxisPlaneConstraint ()


Detailed Description

An abstract class for Frame constraints that use an axis or a plane.

This class defines and implements a translation and a rotation constraint direction and type. The type is defined by the Type() enum which could be extended in derived classes to define new constraint types. The three implementations of this class: LocalConstraint, WorldConstraint and CameraConstraint each define the constraint axis/plane in a different coordinate system.

Different implementations of this class are illustrated in the contrainedCamera and constrainedFrame examples.

To completely forbid the displacement of a Frame, use a code like this:

   AxisPlaneConstraint* apc = new Any_Derived_Class();
   apc->setTranslationConstraintType(AxisPlaneConstraint::FORBIDDEN); // forbids translation
   // apc->setRotationConstraintType(AxisPlaneConstraint::FORBIDDEN); // or forbids rotation
   myFrame->setConstraint(apc);

Attention:
The Axis rotational constraint is implemented by projecting the rotation axis direction of the constrained axis. The constrain is hence satisfied, but unpleasant behavior may appear when a mouse ManipulatedFrame is used to move the frame (try the above examples to see what I mean). A solution would be to directly measure the rotation angle in screen coordinates, but that would imply to know the Camera associated to the viewer, so that we can compute the projected coordinates of the rotation center. This is the way the Camera screen Z axis rotation is implemented (see the mouse page for details). However, we chose not to fix this problem, as it would imply an extra Camera pointer in all the AxisPlaneConstraint derived classes (which the user should have to update depending on the used viewer in a multi-viewer application).


Member Enumeration Documentation

enum Type
 

The different types of translation and rotation constraints that are available. New derived classes can introduce their own enum for specific constraints.

Use setTranslationConstraint() and setRotationConstraint() to set constraints, translationConstraintType() and rotationConstraintType() to get the current constraint type.

Note:
See the warning section of the Detailed Description section for limitations on the AXIS rotational constraint.
Attention:
The PLANE constraint has no effect on a rotational constraint.


Constructor & Destructor Documentation

AxisPlaneConstraint  ) 
 

Translation and Rotation constraints are set to FREE.

virtual ~AxisPlaneConstraint  )  [inline, virtual]
 

Virtual empty destructor.


Member Function Documentation

virtual void constrainRotation Quaternion ,
Frame const
[pure virtual]
 

Default un-constrained rotation function. Desired rotation is expressed in local frame coordinate system. Try the constrainedFrame and constrainedCamera examples for an illustration.

Reimplemented from Constraint.

Implemented in LocalConstraint, WorldConstraint, and CameraConstraint.

virtual void constrainTranslation Vec ,
Frame const
[pure virtual]
 

Default un-constrained translation function. Desired translation is expressed in local frame coordinate system. Try the constrainedFrame and constrainedCamera examples for an illustration.

Reimplemented from Constraint.

Implemented in LocalConstraint, WorldConstraint, and CameraConstraint.

void getRotationConstraintDir float &  x,
float &  y,
float &  z
const
 

Same as getRotationConstraintDir() but result is returned as floats.

void getTranslationConstraintDir float &  x,
float &  y,
float &  z
const
 

Same as getTranslationConstraintDir() but result is returned as floats.

Vec rotationConstraintDir  )  const [inline]
 

Returns the current direction of the rotation constraint. If rotationConstraintType() is FREE or FORBIDDEN, this value is undefined. dir is the plane normal or the axis direction, depending on the constraint. It is expressed in a different coordinate system depending on the derived class (WorldConstraint, CameraConstraint...). This value can be modified with setRotationConstraint().

Type rotationConstraintType  )  const [inline]
 

Returns the current rotation constraint. Result is of type Type(). The rotation constraint is set with setRotationConstraint().

void setRotationConstraint const Type  t,
const float  x,
const float  y,
const float  z
 

Same as setRotationConstraint(), but with float parameters.

void setRotationConstraint const Type  t,
const Vec dir
 

Set possible constraints on the frame rotation. By default, the frame has no rotation constraint.

Type() defines all the possible constraints.

Depending on the value of c, the frame frame will be FREE, will only be able to move around an AXIS, in a PLANE, or will not able to move at all (FORBIDDEN).

The axis and plane normal directions are expressed in different coordinates system, depending on the derived class (WorldConstraint, CameraConstraint...). dir is useless if c is FREE or FORBIDDEN.

Call Frame::setOrientation() or Frame::setRotation() before calling this method in order to define the relative constrained orientation of the frame.

The current constraint is given by rotationConstraintType() and rotationConstraintDir(). The axis direction is undefined when the constraint is of type FREE or FORBIDDEN.

Attention:
The PLANE rotational constraint cannot be used for rotational constraint.

void setRotationConstraintDir const Vec dir  ) 
 

Similar to setRotationConstraint(), but only set the direction.

void setRotationConstraintType const Type  t  ) 
 

Set the Type() of the rotation constraint. See setRotationConstraint().

Attention:
The PLANE Type() cannot be used for rotational constraints.

void setTranslationConstraint const Type  t,
const float  x,
const float  y,
const float  z
 

Same as setTranslationConstraint(), but with float parameters.

void setTranslationConstraint const Type  t,
const Vec dir
 

Set possible constraints on the frame translation. By default, the frame has no translation constraint.

Type() defines all the possible constraints. Depending on the value of c, the frame frame will be FREE, or will not be allowed to move out of a PLANE, or only along an AXIS, or not able to move at all (FORBIDDEN).

The plane is defined by its normal vector and the axis is defined by its direction, both expressed in a coordinate system that depends on the derived class (see translationConstraintDir()).

dir is not used if c is FREE or FORBIDDEN.

Call Frame::setPosition() or Frame::setTranslation() before calling any of this method in order to define the relative constrained position of the frame.

The current constraint is given by translationConstraintType() and translationConstraintDir().

void setTranslationConstraintDir const Vec dir  ) 
 

Similar to setTranslationConstraint(), but only set the direction.

void setTranslationConstraintType const Type  t  )  [inline]
 

Set the Type() of the translation constraint. See setTranslationConstraint().

Vec translationConstraintDir  )  const [inline]
 

Returns the current direction of the translation constraint. If translationConstraintType() is FREE or FORBIDDEN, this value is undefined. dir is the plane normal or the axis direction, depending on the constraint type. It is expressed in different coordinate system, depending on the actual constraint class (camera for CameraConstraint, local for LocalConstraint, world for WorldConstraint, etc.) This value can be modified with setTranslationConstraintDir().

Type translationConstraintType  )  const [inline]
 

Returns the current translation constraint. Result is of type Type(). The translation constraint is set with setTranslationConstraint().


Generated on Mon Jun 14 10:10:15 2004 for libQGLViewer by doxygen 1.3.4