Macro Draw 2D Function/it: Difference between revisions
Renatorivo (talk | contribs) (heading) |
(Updating to match new version of source page) |
||
Line 1: | Line 1: | ||
⚫ | |||
==Traccia una funzione 2D== |
|||
Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane) The example done here generate a parabol.<br /> |
|||
⚫ | |||
Needs to be defined :<br /> |
|||
F = variable used in the function,<br /> |
|||
Si usa per disegnare una funzione descritta da una equazione [z=F(x)] (piano ZX). Questo esempio genera una parabola. |
|||
X = initial value of x,<br /> |
|||
Nb = Number of step,<br /> |
|||
Elementi da definire: |
|||
Z = function express with x <br /> |
|||
ZZ = function express with xx<br /> |
|||
F=variable utilizzata nella funzione, |
|||
X=Valore iniziale di x, |
|||
Nb= Numero di passi, |
|||
Z=Funzione espressa con x |
|||
ZZ=Funzione espressa con xx |
|||
<syntaxhighlight> |
|||
import FreeCAD, FreeCADGui, Part |
import FreeCAD, FreeCADGui, Part |
||
import math |
import math |
||
Line 41: | Line 34: | ||
Part.show(WWire) |
Part.show(WWire) |
||
</syntaxhighlight> |
|||
{{languages/it | {{en|Macro_draw2DFunction}} {{es|Macro_draw2DFunction/es}} {{fr|Macro_draw2DFunction/fr}} }} |
|||
<languages/> |
Revision as of 16:51, 24 December 2013
File:Text-x-python draw2DFunction |
Description |
---|
Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane) |
Author |
[[User:{{{Author}}}|{{{Author}}}]] |
Download |
None |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1.0 |
Date last modified |
None |
FreeCAD Version(s) |
None |
Default shortcut |
None |
See also |
None |
Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane) The example done here generate a parabol.
Needs to be defined :
F = variable used in the function,
X = initial value of x,
Nb = Number of step,
Z = function express with x
ZZ = function express with xx
import FreeCAD, FreeCADGui, Part
import math
F=800
X=-500
Nb=10
Step=1000/Nb
Y=0
for I in range(Nb):
XX=X+Step
Z=X*X/(4*F)
ZZ=XX*XX/(4*F)
if I==0:
print "Le test est vrai !"
nomme=Part.makeLine((X,Y,Z),(XX,Y,ZZ))
WWire=Part.Wire([nomme])
else :
print "Le test est 2 !"
nomme=Part.makeLine((X,Y,Z),(XX,Y,ZZ))
WWire=Part.Wire([WWire,nomme])
X=XX
Part.show(WWire)