Macro Draw 2D Function/sv: Difference between revisions

From FreeCAD Documentation
No edit summary
(Updating to match new version of source page)
Line 1: Line 1:
{{Macro/sv|Icon=Text-x-python|Name=Draw 2D Function|Name/sv=Draw 2D Function|Description=Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane)|Author=unknown}}
{{Macro|Icon=Text-x-python|Name=Draw 2D Function|Description=Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane)|Author=unknown|Version=1.0}}


Använd den för att rita en funktion som beskrivs av en "ekvation" [z=F(x)] (Z-X plan) Exemplet här genererar en parabol. Behöver definieras :
Använd den för att rita en funktion som beskrivs av en "ekvation" [z=F(x)] (Z-X plan) Exemplet här genererar en parabol. Behöver definieras :
Line 14: Line 14:




{{Code|code=
<syntaxhighlight>


# F = variable used in the function,
# F = variable used in the function,
Line 45: Line 45:
Part.show(WWire)
Part.show(WWire)


}}
</syntaxhighlight>
<languages/>
<languages/>

Revision as of 08:49, 26 September 2016

File:Text-x-python Draw 2D Function

Description
Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane)

Macro version: 1.0
Author: unknown
Author
unknown
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

Använd den för att rita en funktion som beskrivs av en "ekvation" [z=F(x)] (Z-X plan) Exemplet här genererar en parabol. Behöver definieras :

F=variabel som används i funktionen,

X=startvärde på x,

Nb= antal steg,

Z=funktionsuttryck med x

ZZ=funktionsuttryck med xx


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