Vector API: Difference between revisions
Renatorivo (talk | contribs) (Marked this version for translation) |
Tag: Undo |
||
(12 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{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]].}} |
|||
⚫ | |||
Vectors are used everywhere in FreeCAD. |
Vectors are used everywhere in FreeCAD. |
||
Line 6: | Line 10: | ||
Example: |
Example: |
||
</translate> |
</translate> |
||
{{Code|code= |
|||
<pre> |
|||
v=FreeCAD.Vector() |
v=FreeCAD.Vector() |
||
v=FreeCAD.Vector(1,0,0) |
v=FreeCAD.Vector(1,0,0) |
||
Line 13: | Line 17: | ||
v3 = v.add(v2) |
v3 = v.add(v2) |
||
print v3.Length |
print v3.Length |
||
}} |
|||
</pre> |
|||
<translate> |
<translate> |
||
<!--T:3--> |
<!--T:3--> |
||
{{APIProperty|Length|returns the length of the vector.}} |
{{APIProperty|Length|returns the length of the vector.}} |
||
⚫ | |||
⚫ | |||
⚫ | |||
{{APIFunction| |
{{APIFunction|distanceToLine|Vector1,Vector2|the distance between the vector and a line through Vector1 in direction Vector2.|float}} |
||
⚫ | |||
⚫ | |||
<!--T:5--> |
|||
{{APIFunction| |
{{APIFunction|dot|Vector|the dot product between 2 vectors.|float}} |
||
⚫ | |||
⚫ | |||
<!--T:6--> |
|||
{{APIFunction| |
{{APIFunction|normalize| |normalizes a vector (sets its length to 1.0).|nothing}} |
||
{{APIFunction|projectToLine|Vector1,Vector2|projects the vector on a line through Vector1 in direction Vector2.|nothing}} |
|||
{{APIFunction|projectToPlane|Vector1,Vector2|projects the vector on a plane defined by a point (Vector1) and a normal (Vector2).|nothing}} |
|||
<!--T:7--> |
|||
{{APIFunction| |
{{APIFunction|scale|Float,Float,Float|Same as multiply but lets specify different values for x, y and z directions. (non-uniform scale)|nothing}} |
||
{{APIFunction|sub|Vector|subtracts another vector from this one.|vector}} |
|||
<!--T:8--> |
|||
⚫ | |||
<!--T:9--> |
|||
⚫ | |||
<!--T:10--> |
|||
⚫ | |||
<!--T:11--> |
|||
{{APIFunction|normalize| |normalizes a vector (sets its length to 1.0).|nothing.}} |
|||
<!--T:12--> |
|||
⚫ | |||
<!--T:13--> |
|||
⚫ | |||
<!--T:14--> |
|||
{{APIFunction|scale|Float,Float,Float|Same as multiply but lets specify different values for x, y and z directions.|nothing.}} |
|||
<!--T:15--> |
|||
⚫ | |||
<!--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--> |
|||
⚫ | |||
</translate> |
</translate> |
||
{{Userdocnavi{{#translation:}}}} |
|||
⚫ | |||
[[Category:Poweruser Documentation{{#translation:}}]] |
|||
{{clear}} |
{{clear}} |
||
⚫ |
Revision as of 13:07, 25 July 2022
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
Description: the distance between the vector and a line through Vector1 in direction Vector2.
Returns: float
Description: a vector to the closest point on a line segment from Vector1 to Vector2.
Returns: vector
Description: the distance between the vector and a plane defined by a point and a normal.
Returns: float
Description: multiplies (uniform scale) a vector by the given factor.
Returns: nothing
Description: projects the vector on a line through Vector1 in direction Vector2.
Returns: nothing
Description: projects the vector on a plane defined by a point (Vector1) and a normal (Vector2).
Returns: nothing
Description: Same as multiply but lets specify different values for x, y and z directions. (non-uniform scale)
Returns: nothing
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Start, Surface, TechDraw, Test Framework, Web
- Hubs: User hub, Power users hub, Developer hub