eXperiment robotics framework

AxisPlaneConstraint Struct Reference

An abstract class for Frame Constraints defined by an axis or a plane. More...

#include <erf_constraint.hpp>

Inheritance diagram for AxisPlaneConstraint:

Inheritance graph
[legend]
Collaboration diagram for AxisPlaneConstraint:

Collaboration graph
[legend]

List of all members.

Public Types

enum  Type { FREE, AXIS, PLANE, FORBIDDEN }

Public Member Functions

 AxisPlaneConstraint ()
virtual ~AxisPlaneConstraint ()
Translation constraint


virtual void constrainTranslation (Vec3 &translation, Frame *const frame)
void setTranslationConstraint (Type type, const Vec3 &direction)
void setTranslationConstraintType (Type type)
void setTranslationConstraintDirection (const Vec3 &direction)
Type translationConstraintType () const
Vec3 translationConstraintDirection () const
Rotation constraint


virtual void constrainRotation (Quaternion &rotation, Frame *const frame)
void setRotationConstraint (Type type, const Vec3 &direction)
void setRotationConstraintType (Type type)
void setRotationConstraintDirection (const Vec3 &direction)
Type rotationConstraintType () const
Vec3 rotationConstraintDirection () const

Protected Attributes

Type translationConstraintType_
Type rotationConstraintType_
Vec3 translationConstraintDir_
Vec3 rotationConstraintDir_


Detailed Description

An abstract class for Frame Constraints defined by an axis or a plane.

AxisPlaneConstraint is an interface for (translation and/or rotation) Constraint that are defined by a direction. translationConstraintType() and rotationConstraintType() define how this direction should be interpreted: as an axis (AxisPlaneConstraint::AXIS) or as a plane normal (AxisPlaneConstraint::PLANE). See the Type() documentation for details.

The three implementations of this class: LocalConstraint, WorldConstraint and CameraConstraint differ by the coordinate system in which this direction is expressed.

Attention:
When applied, the rotational Constraint may not intuitively follow the mouse displacement. A solution would be to directly measure the rotation angle in screen coordinates, but that would imply to know the ERF::camera(), so that we can compute the projected coordinates of the rotation center (as is done with the ERF::SCREEN_ROTATE binding). However, adding an extra pointer to the ERF::camera() in all the AxisPlaneConstraint derived classes (which the user would have to update in a multi-viewer application) was judged as an overkill.

Definition at line 115 of file erf_constraint.hpp.


Member Enumeration Documentation

Type lists the different types of translation and rotation constraints that are available.

It specifies the meaning of the constraint direction (see translationConstraintDirection() and rotationConstraintDirection()): as an axis direction (AxisPlaneConstraint::AXIS) or a plane normal (AxisPlaneConstraint::PLANE). AxisPlaneConstraint::FREE means no constraint while AxisPlaneConstraint::FORBIDDEN completely forbids the translation and/or the rotation.

See translationConstraintType() and rotationConstraintType().

Attention:
The AxisPlaneConstraint::PLANE Type is not valid for rotational constraint.
New derived classes can use their own extended enum for specific constraints:
    class MyAxisPlaneConstraint : public AxisPlaneConstraint
    {
    public:
      enum MyType { FREE, AXIS, PLANE, FORBIDDEN, CUSTOM };
      virtual void constrainTranslation(Vec3 &translation, Frame *const frame)
      {
        // translationConstraintType() is simply an int. CUSTOM Type is handled seamlessly.
        switch (translationConstraintType())
    {
    case MyAxisPlaneConstraint::FREE: ... break;
    case MyAxisPlaneConstraint::CUSTOM: ... break;
    }
      };

      MyAxisPlaneConstraint* c = new MyAxisPlaneConstraint();
      // Note the Type conversion
      c->setTranslationConstraintType(AxisPlaneConstraint::Type(MyAxisPlaneConstraint::CUSTOM));
    };
Enumerator:
FREE 
AXIS 
PLANE 
FORBIDDEN 

Definition at line 149 of file erf_constraint.hpp.


Constructor & Destructor Documentation

AxisPlaneConstraint::AxisPlaneConstraint (  ) 

virtual AxisPlaneConstraint::~AxisPlaneConstraint (  )  [inline, virtual]

Definition at line 118 of file erf_constraint.hpp.


Member Function Documentation

virtual void AxisPlaneConstraint::constrainTranslation ( Vec3 translation,
Frame *const   frame 
) [inline, virtual]

Overloading of Constraint::constrainTranslation(). Empty

Reimplemented from Constraint.

Reimplemented in LocalConstraint, and WorldConstraint.

Definition at line 154 of file erf_constraint.hpp.

void AxisPlaneConstraint::setTranslationConstraint ( Type  type,
const Vec3 direction 
)

void AxisPlaneConstraint::setTranslationConstraintType ( Type  type  )  [inline]

Sets the Type() of the translationConstraintType(). Default is AxisPlaneConstraint::FREE.

Definition at line 158 of file erf_constraint.hpp.

References translationConstraintType_.

void AxisPlaneConstraint::setTranslationConstraintDirection ( const Vec3 direction  ) 

Type AxisPlaneConstraint::translationConstraintType (  )  const [inline]

Returns the translation constraint Type().

Depending on this value, the Frame will freely translate (AxisPlaneConstraint::FREE), will only be able to translate along an axis direction (AxisPlaneConstraint::AXIS), will be forced to stay into a plane (AxisPlaneConstraint::PLANE) or will not able to translate at all (AxisPlaneConstraint::FORBIDDEN).

Use Frame::setPosition() to define the position of the constrained Frame before it gets constrained.

Definition at line 166 of file erf_constraint.hpp.

References translationConstraintType_.

Vec3 AxisPlaneConstraint::translationConstraintDirection (  )  const [inline]

Returns the direction used by the translation constraint.

It represents the axis direction (AxisPlaneConstraint::AXIS) or the plane normal (AxisPlaneConstraint::PLANE) depending on the translationConstraintType(). It is undefined for AxisPlaneConstraint::FREE or AxisPlaneConstraint::FORBIDDEN.

The AxisPlaneConstraint derived classes express this direction in different coordinate system (camera for CameraConstraint, local for LocalConstraint, and world for WorldConstraint). This value can be modified with setTranslationConstraintDirection().

Definition at line 172 of file erf_constraint.hpp.

References translationConstraintDir_.

virtual void AxisPlaneConstraint::constrainRotation ( Quaternion rotation,
Frame *const   frame 
) [inline, virtual]

Overloading of Constraint::constrainRotation(). Empty.

Reimplemented from Constraint.

Reimplemented in LocalConstraint, and WorldConstraint.

Definition at line 178 of file erf_constraint.hpp.

void AxisPlaneConstraint::setRotationConstraint ( Type  type,
const Vec3 direction 
)

void AxisPlaneConstraint::setRotationConstraintType ( Type  type  ) 

void AxisPlaneConstraint::setRotationConstraintDirection ( const Vec3 direction  ) 

Type AxisPlaneConstraint::rotationConstraintType (  )  const [inline]

Returns the rotation constraint Type().

Definition at line 185 of file erf_constraint.hpp.

References rotationConstraintType_.

Vec3 AxisPlaneConstraint::rotationConstraintDirection (  )  const [inline]

Returns the axis direction used by the rotation constraint.

This direction is defined only when rotationConstraintType() is AxisPlaneConstraint::AXIS.

The AxisPlaneConstraint derived classes express this direction in different coordinate system (camera for CameraConstraint, local for LocalConstraint, and world for WorldConstraint). This value can be modified with setRotationConstraintDirection().

Definition at line 191 of file erf_constraint.hpp.


Member Data Documentation

Definition at line 191 of file erf_constraint.hpp.

Referenced by setTranslationConstraintType(), and translationConstraintType().

Definition at line 197 of file erf_constraint.hpp.

Referenced by rotationConstraintType().

Definition at line 199 of file erf_constraint.hpp.

Referenced by translationConstraintDirection().

Definition at line 200 of file erf_constraint.hpp.


The documentation for this struct was generated from the following file:

The miarn project - written by Joao Xavier