Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > cd34bbe24503efb80ebebb7e33511ba0 > files > 107

libQGLViewer-doc-2.3.1-10.fc12.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>libQGLViewer: Constraint Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="../images/qglviewer.ico" type="image/x-icon" /><link rel="icon" href="../images/qglviewer.icon.png" type="image/png" />
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="../index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>

    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
  </div>
</div>
<div class="contents">
<h1>Constraint Class Reference</h1><!-- doxytag: class="qglviewer::Constraint" -->An interface class for <a class="el" href="classqglviewer_1_1Frame.html" title="The Frame class represents a coordinate system, defined by a position and an orientation...">Frame</a> constraints.  
<a href="#_details">More...</a>
<p>
Inherited by <a class="el" href="classqglviewer_1_1AxisPlaneConstraint.html">AxisPlaneConstraint</a>.
<p>

<p>
<a href="classqglviewer_1_1Constraint-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1Constraint.html#65f2b59f5bc1435bf439482d885b0c0a">~Constraint</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1Constraint.html#b7d724965c6765209f47c1abe7f7b7b4">constrainTranslation</a> (<a class="el" href="classqglviewer_1_1Vec.html">Vec</a> &amp;translation, <a class="el" href="classqglviewer_1_1Frame.html">Frame</a> *const frame)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1Constraint.html#5de5f38e75b58476b7926171dba4b31b">constrainRotation</a> (<a class="el" href="classqglviewer_1_1Quaternion.html">Quaternion</a> &amp;rotation, <a class="el" href="classqglviewer_1_1Frame.html">Frame</a> *const frame)</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
An interface class for <a class="el" href="classqglviewer_1_1Frame.html" title="The Frame class represents a coordinate system, defined by a position and an orientation...">Frame</a> constraints. 
<p>
This class defines the interface for the Constraints that can be applied to a <a class="el" href="classqglviewer_1_1Frame.html" title="The Frame class represents a coordinate system, defined by a position and an orientation...">Frame</a> to limit its motion. Use <a class="el" href="classqglviewer_1_1Frame.html#dffa44cd173714b29f2441848a39c224">Frame::setConstraint()</a> to associate a <a class="el" href="classqglviewer_1_1Constraint.html" title="An interface class for Frame constraints.">Constraint</a> to a <a class="el" href="classqglviewer_1_1Frame.html" title="The Frame class represents a coordinate system, defined by a position and an orientation...">Frame</a> (default is a <code>NULL</code> <a class="el" href="classqglviewer_1_1Frame.html#0974dfe336ed84a20adb8c6cdf8dedd9">Frame::constraint()</a>).<p>
<h3>How does it work ?</h3>
<p>
The <a class="el" href="classqglviewer_1_1Constraint.html" title="An interface class for Frame constraints.">Constraint</a> acts as a filter on the translation and rotation <a class="el" href="classqglviewer_1_1Frame.html" title="The Frame class represents a coordinate system, defined by a position and an orientation...">Frame</a> increments. <a class="el" href="classqglviewer_1_1Constraint.html#b7d724965c6765209f47c1abe7f7b7b4">constrainTranslation()</a> and <a class="el" href="classqglviewer_1_1Constraint.html#5de5f38e75b58476b7926171dba4b31b">constrainRotation()</a> should be overloaded to specify the constraint behavior: the desired displacement is given as a parameter that can optionally be modified.<p>
Here is how the <a class="el" href="classqglviewer_1_1Frame.html#4cb0cf5ff79e1acf0755befdaceb6f4a">Frame::translate()</a> and <a class="el" href="classqglviewer_1_1Frame.html#38dffd6ee0ad7e395b49082b2b94de33">Frame::rotate()</a> methods use the <a class="el" href="classqglviewer_1_1Constraint.html" title="An interface class for Frame constraints.">Constraint</a>: <div class="fragment"><pre class="fragment">  <a class="code" href="classqglviewer_1_1Frame.html#4cb0cf5ff79e1acf0755befdaceb6f4a">Frame::translate</a>(Vec&amp; T)
  {
    <span class="keywordflow">if</span> (constraint())
      constraint()-&gt;constrainTranslation(T, <span class="keyword">this</span>);
    t += T;
  }

  Frame::rotate(Quaternion&amp; Q)
  {
    <span class="keywordflow">if</span> (constraint())
      constraint()-&gt;constrainRotation(Q, <span class="keyword">this</span>);
    q *= Q;
  }
</pre></div><p>
The default behavior of <a class="el" href="classqglviewer_1_1Constraint.html#b7d724965c6765209f47c1abe7f7b7b4">constrainTranslation()</a> and <a class="el" href="classqglviewer_1_1Constraint.html#5de5f38e75b58476b7926171dba4b31b">constrainRotation()</a> is empty (meaning no filtering).<p>
The <a class="el" href="classqglviewer_1_1Frame.html" title="The Frame class represents a coordinate system, defined by a position and an orientation...">Frame</a> which uses the <a class="el" href="classqglviewer_1_1Constraint.html" title="An interface class for Frame constraints.">Constraint</a> is passed as a parameter to the <a class="el" href="classqglviewer_1_1Constraint.html#b7d724965c6765209f47c1abe7f7b7b4">constrainTranslation()</a> and <a class="el" href="classqglviewer_1_1Constraint.html#5de5f38e75b58476b7926171dba4b31b">constrainRotation()</a> methods, so that they can have access to its current state (mainly <a class="el" href="classqglviewer_1_1Frame.html#bc38a05a597e07c9ff525122682adc50">Frame::position()</a> and <a class="el" href="classqglviewer_1_1Frame.html#691af39b54669fad8b4e73599de22094">Frame::orientation()</a>). It is not <code>const</code> for versatility reasons, but directly modifying it should be avoided.<p>
<dl class="attention" compact><dt><b>Attention:</b></dt><dd><a class="el" href="classqglviewer_1_1Frame.html#e5495cd791858225ba7c85ce39329704">Frame::setTranslation()</a>, <a class="el" href="classqglviewer_1_1Frame.html#857aacdb88a574ec4a363335f6152a1e">Frame::setRotation()</a> and similar methods will actually indeed set the frame position and orientation, without taking the constraint into account. Use the <em>WithConstraint</em> versions of these methods to enforce the <a class="el" href="classqglviewer_1_1Constraint.html" title="An interface class for Frame constraints.">Constraint</a>.</dd></dl>
<h3>Implemented Constraints</h3>
<p>
Classical axial and plane Constraints are provided for convenience: see the <a class="el" href="classqglviewer_1_1LocalConstraint.html" title="An AxisPlaneConstraint defined in the Frame local coordinate system.">LocalConstraint</a>, <a class="el" href="classqglviewer_1_1WorldConstraint.html" title="An AxisPlaneConstraint defined in the world coordinate system.">WorldConstraint</a> and <a class="el" href="classqglviewer_1_1CameraConstraint.html" title="An AxisPlaneConstraint defined in the camera coordinate system.">CameraConstraint</a> classes' documentations.<p>
Try the <a href="../examples/constrainedFrame.html">constrainedFrame</a> and <a href="../examples/constrainedCamera.html">constrainedCamera</a> examples for an illustration.<p>
<h3>Creating new Constraints</h3>
<p>
The implementation of a new <a class="el" href="classqglviewer_1_1Constraint.html" title="An interface class for Frame constraints.">Constraint</a> class simply consists in overloading the filtering methods: <div class="fragment"><pre class="fragment">  <span class="comment">// This Constraint enforces that the Frame cannot have a negative z world coordinate.</span>
  <span class="keyword">class </span>myConstraint : <span class="keyword">public</span> Constraint
  {
  <span class="keyword">public</span>:
    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classqglviewer_1_1Constraint.html#b7d724965c6765209f47c1abe7f7b7b4">constrainTranslation</a>(Vec&amp; t, Frame * <span class="keyword">const</span> fr)
      {
        <span class="comment">// Express t in the world coordinate system.</span>
        <span class="keyword">const</span> Vec tWorld = fr-&gt;inverseTransformOf(t);
        <span class="keywordflow">if</span> (fr-&gt;position().z + tWorld.z &lt; 0.0) <span class="comment">// check the new fr z coordinate</span>
          t.z = fr-&gt;transformOf(-fr-&gt;position().z); <span class="comment">// t.z is clamped so that next z position is 0.0</span>
      }
  };
</pre></div><p>
Note that the translation (resp. rotation) parameter passed to <a class="el" href="classqglviewer_1_1Constraint.html#b7d724965c6765209f47c1abe7f7b7b4">constrainTranslation()</a> (resp. <a class="el" href="classqglviewer_1_1Constraint.html#5de5f38e75b58476b7926171dba4b31b">constrainRotation()</a>) is expressed in the <em>local</em> <a class="el" href="classqglviewer_1_1Frame.html" title="The Frame class represents a coordinate system, defined by a position and an orientation...">Frame</a> coordinate system. Here, we use the <a class="el" href="classqglviewer_1_1Frame.html#05a3e18419f02427366a95b1e299f12e">Frame::transformOf()</a> and <a class="el" href="classqglviewer_1_1Frame.html#ba2c6c46c1825a81f09d22322b03d9b5">Frame::inverseTransformOf()</a> method to convert it to and from the world coordinate system.<p>
Combined constraints can easily be achieved by creating a new class that applies the different constraint filters: <div class="fragment"><pre class="fragment">  myConstraint::constrainTranslation(Vec&amp; v, Frame* <span class="keyword">const</span> fr)
  {
    constraint1-&gt;constrainTranslation(v, fr);
    constraint2-&gt;constrainTranslation(v, fr);
    <span class="comment">// and so on, with possible branches, tests, loops...</span>
  }
</pre></div> <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="65f2b59f5bc1435bf439482d885b0c0a"></a><!-- doxytag: member="qglviewer::Constraint::~Constraint" ref="65f2b59f5bc1435bf439482d885b0c0a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual ~Constraint           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Virtual destructor. Empty. 
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="b7d724965c6765209f47c1abe7f7b7b4"></a><!-- doxytag: member="qglviewer::Constraint::constrainTranslation" ref="b7d724965c6765209f47c1abe7f7b7b4" args="(Vec &amp;translation, Frame *const frame)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void constrainTranslation           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Vec.html">Vec</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>translation</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Frame.html">Frame</a> *const &nbsp;</td>
          <td class="paramname"> <em>frame</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Filters the translation applied to the <code>frame</code>. This default implementation is empty (no filtering).<p>
Overload this method in your own <a class="el" href="classqglviewer_1_1Constraint.html" title="An interface class for Frame constraints.">Constraint</a> class to define a new translation constraint. <code>frame</code> is the <a class="el" href="classqglviewer_1_1Frame.html" title="The Frame class represents a coordinate system, defined by a position and an orientation...">Frame</a> to which is applied the translation. It is not defined <code>const</code>, but you should refrain from directly changing its value in the constraint. Use its <a class="el" href="classqglviewer_1_1Frame.html#bc38a05a597e07c9ff525122682adc50">Frame::position()</a> and update the <code>translation</code> accordingly instead.<p>
<code>translation</code> is expressed in local frame coordinate system. Use <a class="el" href="classqglviewer_1_1Frame.html#ba2c6c46c1825a81f09d22322b03d9b5">Frame::inverseTransformOf()</a> to express it in the world coordinate system if needed. 
<p>Reimplemented in <a class="el" href="classqglviewer_1_1AxisPlaneConstraint.html#b7d724965c6765209f47c1abe7f7b7b4">AxisPlaneConstraint</a>, <a class="el" href="classqglviewer_1_1LocalConstraint.html#dc695bfbc605b5631be663b28a4ea9f6">LocalConstraint</a>, <a class="el" href="classqglviewer_1_1WorldConstraint.html#dc695bfbc605b5631be663b28a4ea9f6">WorldConstraint</a>, and <a class="el" href="classqglviewer_1_1CameraConstraint.html#dc695bfbc605b5631be663b28a4ea9f6">CameraConstraint</a>.</p>

</div>
</div><p>
<a class="anchor" name="5de5f38e75b58476b7926171dba4b31b"></a><!-- doxytag: member="qglviewer::Constraint::constrainRotation" ref="5de5f38e75b58476b7926171dba4b31b" args="(Quaternion &amp;rotation, Frame *const frame)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void constrainRotation           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Quaternion.html">Quaternion</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>rotation</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Frame.html">Frame</a> *const &nbsp;</td>
          <td class="paramname"> <em>frame</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Filters the rotation applied to the <code>frame</code>. This default implementation is empty (no filtering).<p>
Overload this method in your own <a class="el" href="classqglviewer_1_1Constraint.html" title="An interface class for Frame constraints.">Constraint</a> class to define a new rotation constraint. See <a class="el" href="classqglviewer_1_1Constraint.html#b7d724965c6765209f47c1abe7f7b7b4">constrainTranslation()</a> for details.<p>
Use <a class="el" href="classqglviewer_1_1Frame.html#ba2c6c46c1825a81f09d22322b03d9b5">Frame::inverseTransformOf()</a> on the <code>rotation</code> <a class="el" href="classqglviewer_1_1Quaternion.html#63f3f585fd25e9cb32700a26d54f8ee4">Quaternion::axis()</a> to express <code>rotation</code> in the world coordinate system if needed. 
<p>Reimplemented in <a class="el" href="classqglviewer_1_1AxisPlaneConstraint.html#5de5f38e75b58476b7926171dba4b31b">AxisPlaneConstraint</a>, <a class="el" href="classqglviewer_1_1LocalConstraint.html#71c099a2c356f715f8bf34052875cd25">LocalConstraint</a>, <a class="el" href="classqglviewer_1_1WorldConstraint.html#71c099a2c356f715f8bf34052875cd25">WorldConstraint</a>, and <a class="el" href="classqglviewer_1_1CameraConstraint.html#71c099a2c356f715f8bf34052875cd25">CameraConstraint</a>.</p>

</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>libQGLViewer 2.3.1 documentation generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
</body>
</html>