Macro Draw 2D Function

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Other languages:
Description Draw 2D Function Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane)Macro version: 1.0Last modified: 2011-08-01FreeCAD version: AllDownload: ToolBar IconAuthor: unknown unknown ToolBar Icon Macros recipesHow to install macrosHow to customize toolbars 1.0 2011-08-01 All None None

Description

Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane) The example done here generate a parabol. Has no dialog. 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

Script

ToolBar Icon

Macro_Draw_2D_Function.FCMacro

```# 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 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)```