1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transistional//EN"><html><head><title>OpenLayer Offline Manual</title><style type="text/css" media="all">@import "CrystalStyle.css";</style><body bgcolor="FFFFFF" ><div align="center" style="pagestyle"><table width="60%"><tr><td><div class="parentLinks"><a href="index.html">OpenLayer</a> | <a href="Vec2D.html">Vec2D</a></div><br><div class="BigHeader">Vec2D</div><br><div class=""><div class="Surrounded"><table><tr valign="top"><td align="right"><div class="FuncDef"><strong><a href="Vec2D.html"><font color="#0000CC">Vec2D</font></a>(</strong></div></td><td><div class="FuncDef"><strong><font color="#777733">float</font> x = <font color="#994400">0.0</font>, <font color="#777733">float</font> y = <font color="#994400">0.0</font> )
<br></strong></div></td></tr></table>
<br>Constructs a new vector with the specified components.
<br></div>
<br>The 2D vector class holds the x and y values of the vector which can be directly accessed from the object.
<br>
<br>Several common operators have been overloaded for the vector class. These are sum, subtraction, multiplication, division, normalization (~ -operator) and the dot product (Vec2D * Vec2D). See the exaples to see how to use them.</div><br><div class="MediumHeader">Examples</div><br><div class="Code"><font color="#999922">// Create a new vector called theVector with x = 15.0 and y = 20.0 //</font>
<br><a href="Vec2D.html"><font color="#0000CC">Vec2D</font></a> theVector( <font color="#994400">15.0</font>, <font color="#994400">20.0</font> );
<br>
<br><font color="#999922">// Get the x component of the vector //</font>
<br><font color="#777733">float</font> x = theVector.x;
<br>
<br><font color="#999922">// Get the y component of the vector //</font>
<br><font color="#777733">float</font> y = theVector.y;
<br>
<br><font color="#999922">// Create a new vector called secondVector with x = -50.0 and y = 100.0 //</font>
<br><a href="Vec2D.html"><font color="#0000CC">Vec2D</font></a> secondVector( -<font color="#994400">50.0</font>, <font color="#994400">100.0</font> );
<br>
<br><font color="#999922">// Get a vector sum of theVector and secondVector //</font>
<br><a href="Vec2D.html"><font color="#0000CC">Vec2D</font></a> sum = theVector + secondVector;
<br>
<br><font color="#999922">// Get a vector with 5 times the magnitude of secondVector //</font>
<br><a href="Vec2D.html"><font color="#0000CC">Vec2D</font></a> biggerVector = <font color="#994400">5.0</font> * secondVector;
<br>
<br><font color="#999922">// Increase biggerVector by x = 40, y = -30.5 //</font>
<br>biggerVector += <a href="Vec2D.html"><font color="#0000CC">Vec2D</font></a>( <font color="#994400">40.0</font>, -<font color="#994400">30.5</font> );
<br>
<br><font color="#999922">// Get a normalized copy of biggerVector //</font>
<br><font color="#999922">// (a vector which has the same direction as biggerVector but magnitude of 1.0) //</font>
<br><a href="Vec2D.html"><font color="#0000CC">Vec2D</font></a> normalizedBigger = ~biggerVector;
<br>
<br><font color="#999922">// Get a dot product between two vectors //</font>
<br><font color="#777733">float</font> <font color="#447711">do</font>tProduct = theVector * secondVector;</div><div class=""><br><br><div class="MediumHeader">Member functions</div><div class="Surrounded"><table size="100%" cellpadding="0" cellspacing="0"><tr><td halign="center" class="funclist"><a href="Vec2D/GetMagnitude.html">GetMagnitude</a></td><td width="65%" halign="center"><div class="smalltext">Returns the magnitude (length) of the vector</div></td></tr><tr><td halign="center" class="funclist"><a href="Vec2D/GetAngle.html">GetAngle</a></td><td width="65%" halign="center"><div class="smalltext">Returns the angle of the vector</div></td></tr><tr><td halign="center" class="funclist"><a href="Vec2D/Normalized.html">Normalized</a></td><td width="65%" halign="center"><div class="smalltext">Returns a normalized copy of the vector</div></td></tr><tr><td colspan="2"><br><div class="SmallHeader"><font color="#775500">Advanced functions</font></div><br></td></tr><tr><td halign="center" class="funclist"><a href="Vec2D/GetMagnitudeSquared.html">GetMagnitudeSquared</a></td><td width="65%" halign="center"><div class="smalltext">Returns the squared magnitude of the vector</div></td></tr></table></div><br><div class=""><a href="index.html">Back to the main page of the manual</a></div><br>Questions about Vec2D? Click <a href="http://crystalstorm.ath.cx/index.php?lan=en&page=CreateFeedback&subject=Vec2D">here.</a></div></td></tr></table></body></html>
|