Vector API: Difference between revisions

From FreeCAD Documentation
(translate)
(Marked this version for translation)
Line 1: Line 1:
<translate>
<translate>
<!--T:1-->
Vectors are used everywhere in FreeCAD.
Vectors are used everywhere in FreeCAD.


<!--T:2-->
Example:
Example:
</translate>
</translate>
Line 15: Line 17:




<!--T:3-->
{{APIProperty|Length|returns the length of the vector.}}
{{APIProperty|Length|returns the length of the vector.}}


<!--T:4-->
{{APIFunction|add|Vector|adds another vector to this one|the sum of both vectors.}}
{{APIFunction|add|Vector|adds another vector to this one|the sum of both vectors.}}


<!--T:5-->
{{APIFunction|cross|Vector| |the crossproduct between two vectors.}}
{{APIFunction|cross|Vector| |the crossproduct between two vectors.}}


<!--T:6-->
{{APIFunction|distanceToLine|Vector1,Vector2| |the distance between the vector and a line between Vector1 and Vector2.}}
{{APIFunction|distanceToLine|Vector1,Vector2| |the distance between the vector and a line between Vector1 and Vector2.}}


<!--T:7-->
{{APIFunction|distanceToPlane|Vector1,Vector2| |the distance between the vector and a plane defined by a point and a normal.}}
{{APIFunction|distanceToPlane|Vector1,Vector2| |the distance between the vector and a plane defined by a point and a normal.}}


<!--T:8-->
{{APIFunction|dot|Vector| |the dot product between 2 vectors.}}
{{APIFunction|dot|Vector| |the dot product between 2 vectors.}}


<!--T:9-->
{{APIFunction|getAngle|Vector| |the angle in radians between 2 vectors.}}
{{APIFunction|getAngle|Vector| |the angle in radians between 2 vectors.}}


<!--T:10-->
{{APIFunction|multiply|Float|multiplies (scales) a vector by the given factor|nothing.}}
{{APIFunction|multiply|Float|multiplies (scales) a vector by the given factor|nothing.}}


<!--T:11-->
{{APIFunction|normalize| |normalizes a vector (sets its length to 1.0).|nothing.}}
{{APIFunction|normalize| |normalizes a vector (sets its length to 1.0).|nothing.}}


<!--T:12-->
{{APIFunction|projectToLine|Vector1,Vector2|projects the vector on a line between Vector1 and Vector2.|nothing.}}
{{APIFunction|projectToLine|Vector1,Vector2|projects the vector on a line between Vector1 and Vector2.|nothing.}}


<!--T:13-->
{{APIFunction|projectToPlane|Vector1,Vector2|projects the vector on a plane defined by a point and a normal.|nothing.}}
{{APIFunction|projectToPlane|Vector1,Vector2|projects the vector on a plane defined by a point and a normal.|nothing.}}


<!--T:14-->
{{APIFunction|scale|Float,Float,Float|Same as multiply but lets specify different values for x, y and z directions.|nothing.}}
{{APIFunction|scale|Float,Float,Float|Same as multiply but lets specify different values for x, y and z directions.|nothing.}}


<!--T:15-->
{{APIFunction|sub|Vector|subtracts another vector from the first one.|the resulting vector.}}
{{APIFunction|sub|Vector|subtracts another vector from the first one.|the resulting vector.}}


<!--T:16-->
{{APIProperty|x|the x coordinate of a vector.}}
{{APIProperty|x|the x coordinate of a vector.}}


<!--T:17-->
{{APIProperty|y|the y coordinate of a vector.}}
{{APIProperty|y|the y coordinate of a vector.}}


<!--T:18-->
{{APIProperty|z|the z coordinate of a vector.}}
{{APIProperty|z|the z coordinate of a vector.}}


<!--T:19-->
[[Category:API]]
[[Category:API]]



Revision as of 21:09, 11 November 2014

Vectors are used everywhere in FreeCAD.

Example:

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


Length

Returns: returns the length of the vector.

add(Vector)

Description: adds another vector to this one

Returns: the sum of both vectors.

cross(Vector)

Description:

Returns: the crossproduct between two vectors.

distanceToLine(Vector1,Vector2)

Description:

Returns: the distance between the vector and a line between Vector1 and Vector2.

distanceToPlane(Vector1,Vector2)

Description:

Returns: the distance between the vector and a plane defined by a point and a normal.

dot(Vector)

Description:

Returns: the dot product between 2 vectors.

getAngle(Vector)

Description:

Returns: the angle in radians between 2 vectors.

multiply(Float)

Description: multiplies (scales) a vector by the given factor

Returns: nothing.

normalize( )

Description: normalizes a vector (sets its length to 1.0).

Returns: nothing.

projectToLine(Vector1,Vector2)

Description: projects the vector on a line between Vector1 and Vector2.

Returns: nothing.

projectToPlane(Vector1,Vector2)

Description: projects the vector on a plane defined by a point and a normal.

Returns: nothing.

scale(Float,Float,Float)

Description: Same as multiply but lets specify different values for x, y and z directions.

Returns: nothing.

sub(Vector)

Description: subtracts another vector from the first one.

Returns: the resulting vector.

x

Returns: the x coordinate of a vector.

y

Returns: the y coordinate of a vector.

z

Returns: the z coordinate of a vector.