<html><head><title>Vector API/en</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Vector API/en</h1></div> <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><p>Vectors are used everywhere in FreeCAD. </p><p>Example: </p> <pre>v=FreeCAD.Vector() v=FreeCAD.Vector(1,0,0) v=FreeCAD.Base.Vector() v2 = FreeCAD.Vector(3,2,-5) v3 = v.add(v2) print v3.Length </pre> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Property.png" class="image"><img alt="Property.png" src="Property.png" width="16" height="16" /></a> <big><b>Length</b></big></div> <div class="description"> <p><small><b>Returns</b>:</small> returns the length of the vector. </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>add</b></big> ( <i>Vector</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> adds another vector to this one. </p><p><small><b>Returns</b>:</small> vector </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>cross</b></big> ( <i>Vector</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> the crossproduct between this vector and another. </p><p><small><b>Returns</b>:</small> vector </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>distanceToLine</b></big> ( <i>Vector1,Vector2</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> the distance between the vector and a line through Vector1 in direction Vector2. </p><p><small><b>Returns</b>:</small> float </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>distanceToLineSegment</b></big> ( <i>Vector1,Vector2</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> a vector to the closest point on a line segment from Vector1 to Vector2. </p><p><small><b>Returns</b>:</small> vector </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>distanceToPlane</b></big> ( <i>Vector1,Vector2</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> the distance between the vector and a plane defined by a point and a normal. </p><p><small><b>Returns</b>:</small> float </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>dot</b></big> ( <i>Vector</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> the dot product between 2 vectors. </p><p><small><b>Returns</b>:</small> float </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>getAngle</b></big> ( <i>Vector</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> the angle in radians between this vector and another. </p><p><small><b>Returns</b>:</small> float </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>multiply</b></big> ( <i>Float</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> multiplies (uniform scale) a vector by the given factor. </p><p><small><b>Returns</b>:</small> nothing </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>normalize</b></big> ( <i> </i> )</div> <div class="description"> <p><small><b>Description</b>:</small> normalizes a vector (sets its length to 1.0). </p><p><small><b>Returns</b>:</small> nothing </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>projectToLine</b></big> ( <i>Vector1,Vector2</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> projects the vector on a line through Vector1 in direction Vector2. </p><p><small><b>Returns</b>:</small> nothing </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>projectToPlane</b></big> ( <i>Vector1,Vector2</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> projects the vector on a plane defined by a point (Vector1) and a normal (Vector2). </p><p><small><b>Returns</b>:</small> nothing </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>scale</b></big> ( <i>Float,Float,Float</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> Same as multiply but lets specify different values for x, y and z directions. (non-uniform scale) </p><p><small><b>Returns</b>:</small> nothing </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Method.png" class="image"><img alt="Method.png" src="Method.png" width="16" height="16" /></a> <big><b>sub</b></big> ( <i>Vector</i> )</div> <div class="description"> <p><small><b>Description</b>:</small> subtracts another vector from this one. </p><p><small><b>Returns</b>:</small> vector </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Property.png" class="image"><img alt="Property.png" src="Property.png" width="16" height="16" /></a> <big><b>x</b></big></div> <div class="description"> <p><small><b>Returns</b>:</small> the x coordinate of a vector. </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Property.png" class="image"><img alt="Property.png" src="Property.png" width="16" height="16" /></a> <big><b>y</b></big></div> <div class="description"> <p><small><b>Returns</b>:</small> the y coordinate of a vector. </p> </div> </div> <p><br /> </p> <div class="api"> <div class="function"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Property.png" class="image"><img alt="Property.png" src="Property.png" width="16" height="16" /></a> <big><b>z</b></big></div> <div class="description"> <p><small><b>Returns</b>:</small> the z coordinate of a vector. </p> </div> </div> <div style="clear:both"></div> </div> </div> </div><div class="printfooter"> Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Vector_API/en&oldid=253016">http://www.freecadweb.org/wiki/index.php?title=Vector_API/en&oldid=253016</a>"</div> <div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div> </div> </div> <div id="mw-navigation"> <h2>Navigation menu</h2> </body></html>