Vector API: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
m (Undo revision 1165448 by Marja1 (talk))
Tag: Undo
(4 intermediate revisions by 3 users not shown)
Line 2: Line 2:
<translate>
<translate>
<!--T:1-->
<!--T:1-->
{{VeryImportantMessage|(November 2018) This information may be incomplete and outdated. For the latest API, see the [https://www.freecadweb.org/api autogenerated API documentation].}}
{{VeryImportantMessage|(October 2019) Do not edit this page. The information is incomplete and outdated. For the latest API, see the [https://www.freecadweb.org/api autogenerated API documentation], or generate the documentation yourself, see [[Source documentation|Source documentation]].}}


<!--T:20-->
<!--T:20-->
Line 38: Line 38:
{{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.}}

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


</translate>
</translate>
{{Userdocnavi{{#translation:}}}}
[[Category:API{{#translation:}}]]
[[Category:Poweruser Documentation{{#translation:}}]]
{{clear}}
{{clear}}

Revision as of 13:07, 25 July 2022

(October 2019) Do not edit this page. The information is incomplete and outdated. For the latest API, see the autogenerated API documentation, or generate the documentation yourself, see Source documentation.

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: vector

cross(Vector)

Description: the crossproduct between this vector and another.

Returns: vector

distanceToLine(Vector1,Vector2)

Description: the distance between the vector and a line through Vector1 in direction Vector2.

Returns: float

distanceToLineSegment(Vector1,Vector2)

Description: a vector to the closest point on a line segment from Vector1 to Vector2.

Returns: vector

distanceToPlane(Vector1,Vector2)

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

Returns: float

dot(Vector)

Description: the dot product between 2 vectors.

Returns: float

getAngle(Vector)

Description: the angle in radians between this vector and another.

Returns: float

multiply(Float)

Description: multiplies (uniform scale) 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 through Vector1 in direction Vector2.

Returns: nothing

projectToPlane(Vector1,Vector2)

Description: projects the vector on a plane defined by a point (Vector1) and a normal (Vector2).

Returns: nothing

scale(Float,Float,Float)

Description: Same as multiply but lets specify different values for x, y and z directions. (non-uniform scale)

Returns: nothing

sub(Vector)

Description: subtracts another vector from this one.

Returns: 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.