| 0 | 1 <html> | 
|  | 2 <head> | 
|  | 3 <title>MayaChemTools:Documentation:Vector.pm</title> | 
|  | 4 <meta http-equiv="content-type" content="text/html;charset=utf-8"> | 
|  | 5 <link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css"> | 
|  | 6 </head> | 
|  | 7 <body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10"> | 
|  | 8 <br/> | 
|  | 9 <center> | 
|  | 10 <a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a> | 
|  | 11 </center> | 
|  | 12 <br/> | 
|  | 13 <div class="DocNav"> | 
|  | 14 <table width="100%" border=0 cellpadding=0 cellspacing=2> | 
|  | 15 <tr align="left" valign="top"><td width="33%" align="left"><a href="./TimeUtil.html" title="TimeUtil.html">Previous</a>  <a href="./index.html" title="Table of Contents">TOC</a>  </td><td width="34%" align="middle"><strong>Vector.pm</strong></td><td width="33%" align="right"><a href="././code/Vector.html" title="View source code">Code</a> | <a href="./../pdf/Vector.pdf" title="PDF US Letter Size">PDF</a> | <a href="./../pdfgreen/Vector.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a> | <a href="./../pdfa4/Vector.pdf" title="PDF A4 Size">PDFA4</a> | <a href="./../pdfa4green/Vector.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr> | 
|  | 16 </table> | 
|  | 17 </div> | 
|  | 18 <p> | 
|  | 19 </p> | 
|  | 20 <h2>NAME</h2> | 
|  | 21 <p>Vector</p> | 
|  | 22 <p> | 
|  | 23 </p> | 
|  | 24 <h2>SYNOPSIS</h2> | 
|  | 25 <p>use Vector;</p> | 
|  | 26 <p>use Vector qw(:all);</p> | 
|  | 27 <p> | 
|  | 28 </p> | 
|  | 29 <h2>DESCRIPTION</h2> | 
|  | 30 <p><strong>Vector</strong> class provides the following methods:</p> | 
|  | 31 <p> <a href="#new">new</a>, <a href="#addvalues">AddValues</a>, <a href="#copy">Copy</a>, <a href="#getlength">GetLength</a>, <a href="#getmagnitude">GetMagnitude</a>, <a href="#getnumofnonzerovalues">GetNumOfNonZeroValues</a> | 
|  | 32 , <a href="#getpercentofnonzerovalues">GetPercentOfNonZeroValues</a>, <a href="#getsize">GetSize</a>, <a href="#getvalue">GetValue</a>, <a href="#getvalues">GetValues</a>, <a href="#getx">GetX</a>, <a href="#getxyz">GetXYZ</a>, <a href="#gety">GetY</a> | 
|  | 33 , <a href="#getz">GetZ</a>, <a href="#isvector">IsVector</a>, <a href="#normalize">Normalize</a>, <a href="#setvalue">SetValue</a>, <a href="#setvalueprintformat">SetValuePrintFormat</a> | 
|  | 34 , <a href="#setx">SetX</a>, <a href="#setxyz">SetXYZ</a>, <a href="#sety">SetY</a>, <a href="#setz">SetZ</a>, <a href="#stringifyvector">StringifyVector</a>, <a href="#isvector">IsVector</a> | 
|  | 35 </p><p>The following functions are available:</p> | 
|  | 36 <p>IsVector, SetValuePrintFormat UnitXVector, UnitYVector, UnitZVector, UnitVector, | 
|  | 37 ZeroVector</p> | 
|  | 38 <p>The following operators are overloaded:</p> | 
|  | 39 <div class="OptionsBox"> | 
|  | 40     "" 0+ bool | 
|  | 41 <br/>    @{} | 
|  | 42 <br/>    + - * / % | 
|  | 43 <br/>    x . | 
|  | 44 <br/>    == != < <= > >= | 
|  | 45 <br/>    neg | 
|  | 46 <br/>    abs exp log sqrt cos sin</div> | 
|  | 47 <p> | 
|  | 48 </p> | 
|  | 49 <h2>FUNCTIONS</h2> | 
|  | 50 <dl> | 
|  | 51 <dt><strong><a name="new" class="item"><strong>new</strong></a></strong></dt> | 
|  | 52 <dd> | 
|  | 53 <div class="OptionsBox"> | 
|  | 54     $NewVector = new Vector(); | 
|  | 55 <br/>    $NewVector = new Vector(@Values); | 
|  | 56 <br/>    $NewVector = new Vector(\@Values); | 
|  | 57 <br/>    $NewVector = new Vector($AnotherVector);</div> | 
|  | 58 <p>Creates a new <strong>Vector</strong> object containing <em>Values</em> and returns <strong>NewVector</strong> object. | 
|  | 59 In case no <em>Values</em> are specified, an empty <strong>Vector</strong> is created.</p> | 
|  | 60 </dd> | 
|  | 61 <dt><strong><a name="addvalues" class="item"><strong>AddValues</strong></a></strong></dt> | 
|  | 62 <dd> | 
|  | 63 <div class="OptionsBox"> | 
|  | 64     $Vector->AddValues(@Values); | 
|  | 65 <br/>    $Vector->AddValues(\@Values); | 
|  | 66 <br/>    $Vector->AddValues($AnotherVector);</div> | 
|  | 67 <p>Adds values to <em>Vector</em> using an array, reference to an array or another vector and returns | 
|  | 68 <em>Vector</em>.</p> | 
|  | 69 </dd> | 
|  | 70 <dt><strong><a name="copy" class="item"><strong>Copy</strong></a></strong></dt> | 
|  | 71 <dd> | 
|  | 72 <div class="OptionsBox"> | 
|  | 73     $NewVector = $Vector->Copy();</div> | 
|  | 74 <p>Creates a copy of <em>Vector</em> and returns <em>NewVector</em>.</p> | 
|  | 75 </dd> | 
|  | 76 <dt><strong><a name="getlength" class="item"><strong>GetLength</strong></a></strong></dt> | 
|  | 77 <dd> | 
|  | 78 <div class="OptionsBox"> | 
|  | 79     $Length = $Vector->GetLength();</div> | 
|  | 80 <p>Returns <em>Lengh</em> of a 3D <em>Vector</em> corresponding to its dot product.</p> | 
|  | 81 </dd> | 
|  | 82 <dt><strong><a name="getmagnitude" class="item"><strong>GetMagnitude</strong></a></strong></dt> | 
|  | 83 <dd> | 
|  | 84 <div class="OptionsBox"> | 
|  | 85     $Length = $Vector->GetMagnitude();</div> | 
|  | 86 <p>Returns <em>Lengh</em> of a 3D <em>Vector</em> corresponding to its dot product.</p> | 
|  | 87 </dd> | 
|  | 88 <dt><strong><a name="getnumofnonzerovalues" class="item"><strong>GetNumOfNonZeroValues</strong></a></strong></dt> | 
|  | 89 <dd> | 
|  | 90 <div class="OptionsBox"> | 
|  | 91     $Value = $Vector->GetNumOfNonZeroValues();</div> | 
|  | 92 <p>Returns number of non-zero values in <em>Vector</em>.</p> | 
|  | 93 </dd> | 
|  | 94 <dt><strong><a name="getpercentofnonzerovalues" class="item"><strong>GetPercentOfNonZeroValues</strong></a></strong></dt> | 
|  | 95 <dd> | 
|  | 96 <div class="OptionsBox"> | 
|  | 97     $Value = $Vector->GetPercentOfNonZeroValues();</div> | 
|  | 98 <p>Returns percent of non-zero values in <em>Vector</em>.</p> | 
|  | 99 </dd> | 
|  | 100 <dt><strong><a name="getsize" class="item"><strong>GetSize</strong></a></strong></dt> | 
|  | 101 <dd> | 
|  | 102 <div class="OptionsBox"> | 
|  | 103     $Size = $Vector->GetSize();</div> | 
|  | 104 <p>Returns size of a <em>Vector</em> corresponding to number of its values.</p> | 
|  | 105 </dd> | 
|  | 106 <dt><strong><a name="getvalue" class="item"><strong>GetValue</strong></a></strong></dt> | 
|  | 107 <dd> | 
|  | 108 <div class="OptionsBox"> | 
|  | 109     $Value = $Vector->GetValues($Index);</div> | 
|  | 110 <p>Returns vector <strong>Value</strong> specified using <em>Index</em> starting at 0.</p> | 
|  | 111 </dd> | 
|  | 112 <dt><strong><a name="getvalues" class="item"><strong>GetValues</strong></a></strong></dt> | 
|  | 113 <dd> | 
|  | 114 <div class="OptionsBox"> | 
|  | 115     @Values = $Vector->GetValues(); | 
|  | 116 <br/>    $ValuesRef = $Vector->GetValues();</div> | 
|  | 117 <p>Returns an array or a reference to an array containing all <em>Vector</em> values.</p> | 
|  | 118 </dd> | 
|  | 119 <dt><strong><a name="getx" class="item"><strong>GetX</strong></a></strong></dt> | 
|  | 120 <dd> | 
|  | 121 <div class="OptionsBox"> | 
|  | 122     $X = $Vector->GetX();</div> | 
|  | 123 <p>Returns <strong>X</strong> value of a 3D <em>Vector</em></p> | 
|  | 124 </dd> | 
|  | 125 <dt><strong><a name="getxyz" class="item"><strong>GetXYZ</strong></a></strong></dt> | 
|  | 126 <dd> | 
|  | 127 <div class="OptionsBox"> | 
|  | 128     @XYZValues = $Vector->GetXYZ(); | 
|  | 129 <br/>    $XYZValuesRef = $Vector->GetXYZ();</div> | 
|  | 130 <p>Returns <strong>XYZ</strong> values of a 3D <em>Vector</em> as an array or a reference to an array | 
|  | 131 containing the values.</p> | 
|  | 132 </dd> | 
|  | 133 <dt><strong><a name="gety" class="item"><strong>GetY</strong></a></strong></dt> | 
|  | 134 <dd> | 
|  | 135 <div class="OptionsBox"> | 
|  | 136     $Y = $Vector->GetY();</div> | 
|  | 137 <p>Returns <strong>Y</strong> value of a 3D <em>Vector</em>.</p> | 
|  | 138 </dd> | 
|  | 139 <dt><strong><a name="getz" class="item"><strong>GetZ</strong></a></strong></dt> | 
|  | 140 <dd> | 
|  | 141 <div class="OptionsBox"> | 
|  | 142     $Z = $Vector->GetZ();</div> | 
|  | 143 <p>Returns <strong>Z</strong> value of a 3D <em>Vector</em>.</p> | 
|  | 144 </dd> | 
|  | 145 <dt><strong><a name="isvector" class="item"><strong>IsVector</strong></a></strong></dt> | 
|  | 146 <dd> | 
|  | 147 <div class="OptionsBox"> | 
|  | 148     $Status = Vector::IsVector($Object);</div> | 
|  | 149 <p>Returns 1 or 0 based on whether <em>Object</em> is a <strong>Vector</strong> object.</p> | 
|  | 150 </dd> | 
|  | 151 <dt><strong><a name="normalize" class="item"><strong>Normalize</strong></a></strong></dt> | 
|  | 152 <dd> | 
|  | 153 <div class="OptionsBox"> | 
|  | 154     $Vector->Normalize();</div> | 
|  | 155 <p>Normalizes a 3D <em>Vector</em> by dividing its values by the length and returns <em>Vector</em>.</p> | 
|  | 156 </dd> | 
|  | 157 <dt><strong><a name="setvalue" class="item"><strong>SetValue</strong></a></strong></dt> | 
|  | 158 <dd> | 
|  | 159 <div class="OptionsBox"> | 
|  | 160     $Vector->SetValue($Index, $Value);</div> | 
|  | 161 <p>Sets a <em>Vector</em> value specified by <em>Index</em> to <em>Value</em> and returns <em>Vector</em>.</p> | 
|  | 162 </dd> | 
|  | 163 <dt><strong><a name="setvalueprintformat" class="item"><strong>SetValuePrintFormat</strong></a></strong></dt> | 
|  | 164 <dd> | 
|  | 165 <div class="OptionsBox"> | 
|  | 166     $Vector->SetValuePrintFormat($ValuePrintFormat); | 
|  | 167 <br/>    Vector::SetValuePrintFormat($ValuePrintFormat);</div> | 
|  | 168 <p>Sets format for printing vector values for a specified <em>Vector</em> or the whole class. Default | 
|  | 169 format: <em>%g</em>.</p> | 
|  | 170 </dd> | 
|  | 171 <dt><strong><a name="setx" class="item"><strong>SetX</strong></a></strong></dt> | 
|  | 172 <dd> | 
|  | 173 <div class="OptionsBox"> | 
|  | 174     $Vector->SetX($Value);</div> | 
|  | 175 <p>Sets <strong>X</strong> value of a 3D vector to <em>Value</em> and returns <em>Vector</em>.</p> | 
|  | 176 </dd> | 
|  | 177 <dt><strong><a name="setxyz" class="item"><strong>SetXYZ</strong></a></strong></dt> | 
|  | 178 <dd> | 
|  | 179 <div class="OptionsBox"> | 
|  | 180     $Vector->SetXYZ(@Values); | 
|  | 181 <br/>    $Vector->SetXYZ(\@Values); | 
|  | 182 <br/>    $Vector->SetXYZ($AnotherVector);</div> | 
|  | 183 <p>Sets <strong>XYZ</strong> values of a 3D vector and returns <em>Vector</em>.</p> | 
|  | 184 </dd> | 
|  | 185 <dt><strong><a name="sety" class="item"><strong>SetY</strong></a></strong></dt> | 
|  | 186 <dd> | 
|  | 187 <div class="OptionsBox"> | 
|  | 188     $Vector->SetY($Value);</div> | 
|  | 189 <p>Sets <strong>Y</strong> value of a 3D vector to <em>Value</em> and returns <em>Vector</em>.</p> | 
|  | 190 </dd> | 
|  | 191 <dt><strong><a name="setz" class="item"><strong>SetZ</strong></a></strong></dt> | 
|  | 192 <dd> | 
|  | 193 <div class="OptionsBox"> | 
|  | 194     $Vector->SetZ($Value);</div> | 
|  | 195 <p>Sets <strong>Z</strong> value of a 3D vector to <em>Value</em> and returns <em>Vector</em>.</p> | 
|  | 196 </dd> | 
|  | 197 <dt><strong><a name="stringifyvector" class="item"><strong>StringifyVector</strong></a></strong></dt> | 
|  | 198 <dd> | 
|  | 199 <div class="OptionsBox"> | 
|  | 200     $String = $Vector->StringifyVector();</div> | 
|  | 201 <p>Returns a string containing information about <em>Vector</em> object.</p> | 
|  | 202 </dd> | 
|  | 203 <dt><strong><a name="unitvector" class="item"><strong>UnitVector</strong></a></strong></dt> | 
|  | 204 <dd> | 
|  | 205 <div class="OptionsBox"> | 
|  | 206     $UnitVector = UnitVector([$Size]); | 
|  | 207 <br/>    $UnitVector = Vector::UnitVector([$Size]);</div> | 
|  | 208 <p>Returns a <strong>UnitVector</strong> of <em>Size</em>. Default size: <em>3</em>.</p> | 
|  | 209 </dd> | 
|  | 210 <dt><strong><a name="unitxvector" class="item"><strong>UnitXVector</strong></a></strong></dt> | 
|  | 211 <dd> | 
|  | 212 <div class="OptionsBox"> | 
|  | 213     $UnitXVector = UnitXVector();</div> | 
|  | 214 <p>Returns a 3D <strong>UnitXVector</strong>.</p> | 
|  | 215 </dd> | 
|  | 216 <dt><strong><a name="unityvector" class="item"><strong>UnitYVector</strong></a></strong></dt> | 
|  | 217 <dd> | 
|  | 218 <div class="OptionsBox"> | 
|  | 219     $UnitYVector = UnitYVector();</div> | 
|  | 220 <p>Returns a 3D <strong>UnitYVector</strong>.</p> | 
|  | 221 </dd> | 
|  | 222 <dt><strong><a name="unitzvector" class="item"><strong>UnitZVector</strong></a></strong></dt> | 
|  | 223 <dd> | 
|  | 224 <div class="OptionsBox"> | 
|  | 225     $UnitZVector = UnitZVector();</div> | 
|  | 226 <p>Returns a 3D <strong>UnitZVector</strong>.</p> | 
|  | 227 </dd> | 
|  | 228 <dt><strong><a name="zerovector" class="item"><strong>ZeroVector</strong></a></strong></dt> | 
|  | 229 <dd> | 
|  | 230 <div class="OptionsBox"> | 
|  | 231     $UnitVector = ZeroVector([$Size]); | 
|  | 232 <br/>    $UnitVector = Vector::ZeroVector([$Size]);</div> | 
|  | 233 <p>Returns a <strong>ZeroVector</strong> of <em>Size</em>. Default size: <em>3</em>.</p> | 
|  | 234 </dd> | 
|  | 235 </dl> | 
|  | 236 <p> | 
|  | 237 </p> | 
|  | 238 <h2>AUTHOR</h2> | 
|  | 239 <p><a href="mailto:msud@san.rr.com">Manish Sud</a></p> | 
|  | 240 <p> | 
|  | 241 </p> | 
|  | 242 <h2>SEE ALSO</h2> | 
|  | 243 <p><a href="./BitVector.html">BitVector.pm</a> | 
|  | 244 </p> | 
|  | 245 <p> | 
|  | 246 </p> | 
|  | 247 <h2>COPYRIGHT</h2> | 
|  | 248 <p>Copyright (C) 2015 Manish Sud. All rights reserved.</p> | 
|  | 249 <p>This file is part of MayaChemTools.</p> | 
|  | 250 <p>MayaChemTools is free software; you can redistribute it and/or modify it under | 
|  | 251 the terms of the GNU Lesser General Public License as published by the Free | 
|  | 252 Software Foundation; either version 3 of the License, or (at your option) | 
|  | 253 any later version.</p> | 
|  | 254 <p> </p><p> </p><div class="DocNav"> | 
|  | 255 <table width="100%" border=0 cellpadding=0 cellspacing=2> | 
|  | 256 <tr align="left" valign="top"><td width="33%" align="left"><a href="./TimeUtil.html" title="TimeUtil.html">Previous</a>  <a href="./index.html" title="Table of Contents">TOC</a>  </td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>Vector.pm</strong></td></tr> | 
|  | 257 </table> | 
|  | 258 </div> | 
|  | 259 <br /> | 
|  | 260 <center> | 
|  | 261 <img src="../../images/h2o2.png"> | 
|  | 262 </center> | 
|  | 263 </body> | 
|  | 264 </html> |