Vector API/es: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 13: Line 13:


{{APIProperty|Length|returns the length of the vector.}}
{{APIProperty|Length|returns the length of the vector.}}

{{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.}}

{{APIFunction|cross|Vector| |the crossproduct between two vectors.}}
{{APIFunction|cross|Vector| |the crossproduct between two vectors.}}

{{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.}}

{{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.}}

{{APIFunction|dot|Vector| |the dot product between 2 vectors.}}
{{APIFunction|dot|Vector| |the dot product between 2 vectors.}}

{{APIFunction|getAngle|Vector| |the angle in radians between 2 vectors.}}
{{APIFunction|getAngle|Vector| |the angle in radians between 2 vectors.}}

{{APIFunction|multiply|Float|multiplies (scales) a vector by the given factor|nothing.}}
{{APIFunction|multiply|Float|multiplies (scales) a vector by the given factor|nothing.}}

{{APIFunction|normalize| |normalizes a vector (sets its length to 1.0).|nothing.}}
{{APIFunction|normalize| |normalizes a vector (sets its length to 1.0).|nothing.}}

{{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.}}

{{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.}}

{{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.}}

{{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.}}

{{APIProperty|x|the x coordinate of a vector.}}
{{APIProperty|x|the x coordinate of a vector.}}

{{APIProperty|y|the y coordinate of a vector.}}
{{APIProperty|y|the y coordinate of a vector.}}

{{APIProperty|z|the z coordinate of a vector.}}
{{APIProperty|z|the z coordinate of a vector.}}



Revision as of 22:56, 15 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.

Other languages: