Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

CappedRectangle Class Reference

#include <CappedRectangle.h>

Inheritance diagram for CappedRectangle:

PhysicalObject GraphicalObject List of all members.

Public Member Functions

Public Attributes

Private Member Functions


Detailed Description

Defines a rectangle having the thin ends capped with half circles. The base position (relative to which the rotation angle is measured) is along the x axis, like this: (______). l is the half length of the rectangle, R its half width. The end half circles have a radius R.

Definition at line 13 of file CappedRectangle.h.


Constructor & Destructor Documentation

CappedRectangle::CappedRectangle real  l,
real  R,
real  x = 0,
real  y = 0,
real  alpha = 0,
std::string  label = "",
int  nSensorsLateral = 0,
int  nSensorsSemicircle = 0,
real  saturationForce = 0.5,
Color  outlineColor = GUI::colorBlack,
Color  fillColor = GUI::colorTransparent
 

Definition at line 6 of file CappedRectangle.cpp.

References computeBox(), computeInertia(), computeMass(), Vector2::x, and Vector2::y.

CappedRectangle::~CappedRectangle  )  [virtual]
 

Destructor, does nothing.

Definition at line 26 of file CappedRectangle.cpp.


Member Function Documentation

virtual void CappedRectangle::computeBox  )  [inline, virtual]
 

Computes the coordinates of the bounding box. It is called after each call to integrate() or rollback().

Reimplemented from PhysicalObject.

Definition at line 50 of file CappedRectangle.h.

References cosAlpha, and sinAlpha.

Referenced by CappedRectangle().

void CappedRectangle::computeInertia  )  [virtual]
 

Computes the moment of inertia around the z axis that passes through the center

Reimplemented from PhysicalObject.

Definition at line 34 of file CappedRectangle.cpp.

References l, and R.

Referenced by CappedRectangle().

void CappedRectangle::computeMass real  density = ThyrixParameters::defaultDensity  )  [virtual]
 

Sets the mass based on the dimensions and the density

Reimplemented from PhysicalObject.

Definition at line 29 of file CappedRectangle.cpp.

References l, and R.

Referenced by CappedRectangle().

bool CappedRectangle::detectContacts CappedRectangle capsule,
GlobalContactInfoVector contacts
[virtual]
 

Tests for contacts between this object and another capped rectangle

Reimplemented from PhysicalObject.

Definition at line 299 of file CappedRectangle.cpp.

References cosAlpha, getISensorLateral(), getISensorSemicircle(), Vector2::getModule(), Vector2::getSquaredModule(), l, M_PI, Vector2::normalize(), PhysicalObject::r, R, real, setISensorLateral(), Vector2::setXY(), sinAlpha, sqr(), Vector2::x, and Vector2::y.

bool CappedRectangle::detectContacts Circle circle,
GlobalContactInfoVector contacts
[virtual]
 

Tests for contacts between this object and a circle.

Reimplemented from PhysicalObject.

Definition at line 189 of file CappedRectangle.cpp.

References cosAlpha, Circle::getISensor(), getISensorLateral(), getISensorSemicircle(), Vector2::getModule(), l, M_PI, Vector2::normalize(), Circle::R, R, PhysicalObject::r, real, Vector2::setXY(), sinAlpha, sqr(), Vector2::x, and Vector2::y.

bool CappedRectangle::detectContacts Border border,
GlobalContactInfoVector contacts
[virtual]
 

Tests for contacts between this object and a border.

Reimplemented from PhysicalObject.

Definition at line 92 of file CappedRectangle.cpp.

References cosAlpha, getISensorSemicircle(), l, Border::normal, PhysicalObject::r, real, setISensorLateral(), Vector2::setToZero(), sinAlpha, sqr(), Vector2::x, and Vector2::y.

virtual bool CappedRectangle::detectContacts PhysicalObject object,
GlobalContactInfoVector contacts
[inline, virtual]
 

Contact handling.

Implements PhysicalObject.

Definition at line 31 of file CappedRectangle.h.

References PhysicalObject::detectContacts().

bool CappedRectangle::detectMouseContact const Vector2 rMouse,
Vector2 p,
PhysicalObject *&  object
[virtual]
 

Detects whether a click of the mouse at rMouse has touched the object. In case of contact, returns true and sets p to the relative vector between the center of the object and the contact point; p is expressed in the object reference frame because it rotates with the object while the object is dragged.

Reimplemented from PhysicalObject.

Definition at line 618 of file CappedRectangle.cpp.

References cosAlpha, Vector2::getModule(), l, real, Vector2::rotate(), Vector2::setXY(), sinAlpha, Vector2::x, and Vector2::y.

void CappedRectangle::draw GUI gui  )  [virtual]
 

Draws the object on the user interface.

Implements GraphicalObject.

Definition at line 683 of file CappedRectangle.cpp.

References GUI::drawCappedRectangle(), l, R, GUI::setBrushColor(), GUI::setPenColor(), Vector2::x, and Vector2::y.

void CappedRectangle::drawSensors GUI gui  ) 
 

Draws the object's tactile sensors.

Definition at line 693 of file CappedRectangle.cpp.

References GUI::drawLine(), l, M_PI, nSensorsLateral, R, real, Vector2::x, and Vector2::y.

int CappedRectangle::getISensorLateral real  side,
real  e
[private]
 

Returns the index of the lateral sensor corresponding to a contact given by e and the side of the capsule (a positive value corresponds to the top side of the capsule, a negative value to the bottom side). The projection of the contact point on the capsule axis is at a distance e from the capsule center (e can be positive or negative).

Definition at line 72 of file CappedRectangle.cpp.

References l, and nSensorsLateral.

int CappedRectangle::getISensorLateral Vector2 p,
real  e
[private]
 

Returns the index of the lateral sensor corresponding to a contact given by e and the vector p relative to the center of the capsule. The projection of the contact point on the capsule axis is at a distance e from the capsule center (e can be positive or negative).

Definition at line 67 of file CappedRectangle.cpp.

References getLateralSide(), and real.

Referenced by detectContacts(), and setISensorLateral().

int CappedRectangle::getISensorSemicircle Vector2 p,
int  sign
[private]
 

Gets the index of a tactile sensor on a semicircle, given the relative vector p from the end of the capsule's axis to the contact point, and the sign (+ or -) that determins one of the 2 ends of the capsule's axis.

Definition at line 38 of file CappedRectangle.cpp.

References M_PI, nSensorsLateral, nSensorsSemicircle, real, Vector2::x, and Vector2::y.

Referenced by detectContacts().

real CappedRectangle::getLateralSide Vector2 p  )  [inline, private]
 

Returns the side on which exists a contact given by the vector p relative to the center of the capsule. A positive returned value corresponds to the top side of the capsule, a negative value to the bottom side.

Definition at line 109 of file CappedRectangle.h.

References real, sinAlpha, Vector2::x, and Vector2::y.

Referenced by getISensorLateral(), and setISensorLateral().

void CappedRectangle::setISensorLateral int &  i1,
int &  i2,
Vector2 p,
real  e1,
real  e2
[private]
 

Gets the index of a tactile sensor on a lateral of the capsule, given the side of the capsule determined by the normal component (relative to the capsule's axis) of the vector p, and the linear coordinates of the ends of the lateral contact on the capsule's axis. sinAlpha and cosAlpha are passed as they are already computed.

Definition at line 61 of file CappedRectangle.cpp.

References getISensorLateral(), getLateralSide(), and real.

Referenced by detectContacts().

void CappedRectangle::setSensor ContactInfo contact  )  [virtual]
 

Sets the activation of a tactile sensor, corresponding to the given contact. To be overridden.

Reimplemented from PhysicalObject.

Definition at line 647 of file CappedRectangle.cpp.

References ContactInfo::force, ContactInfo::iSensor, ContactInfo::iSensor2, real, and ContactInfo::type.


Member Data Documentation

real CappedRectangle::cosAlpha
 

Cosinus of alpha. Always updated.

Definition at line 74 of file CappedRectangle.h.

Referenced by computeBox(), VisualSensor::detectContacts(), detectContacts(), and detectMouseContact().

real CappedRectangle::l
 

Dimensions; l is the half length of the rectangle, R its half width. The end half circles will have radius R.

Definition at line 70 of file CappedRectangle.h.

Referenced by computeInertia(), computeMass(), VisualSensor::detectContacts(), detectContacts(), detectMouseContact(), draw(), drawSensors(), and getISensorLateral().

unsigned CappedRectangle::nSensorsLateral
 

The number of tactile sensors per lateral of the rectangle.

Definition at line 79 of file CappedRectangle.h.

Referenced by drawSensors(), getISensorLateral(), and getISensorSemicircle().

unsigned CappedRectangle::nSensorsSemicircle
 

The number of tactile sensors per end semicircle.

Definition at line 82 of file CappedRectangle.h.

Referenced by getISensorSemicircle().

real CappedRectangle::R
 

Definition at line 71 of file CappedRectangle.h.

Referenced by computeInertia(), computeMass(), VisualSensor::detectContacts(), detectContacts(), draw(), and drawSensors().

real CappedRectangle::sinAlpha
 

Sinus of alpha. Always updated.

Definition at line 76 of file CappedRectangle.h.

Referenced by computeBox(), VisualSensor::detectContacts(), detectContacts(), detectMouseContact(), and getLateralSide().


The documentation for this class was generated from the following files:

Thyrix homepageUsers' guide

(C) Arxia 2004-2005