Macro Draw Parametric 2D Function/de: Difference between revisions
(Updating to match new version of source page) |
No edit summary |
||
(23 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
{{Macro|Icon=Text-x-python|Name=Macro DrawParametric2DFunction|Description=Draws 2-dimensional, parametric and optionally polar equations.|Author=T4b}} |
|||
{{Macro/de |
|||
|Name=Macro Draw Parametric 2D Function |
|||
|Icon=Macro_Draw_Parametric_2D_Function.png |
|||
|Translate=Macro Draw Parametric 2D Function |
|||
|Description=Zeichnet 2-dimensionale, parametrische und optional polare Gleichungen. |
|||
|Author=T4b |
|||
|Version=1.0 |
|||
|Date=2012-08-30 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/0/03/Macro_Draw_Parametric_2D_Function.png ToolBar Icon] |
|||
⚫ | |||
==Beschreibung== |
|||
⚫ | |||
Zeichnet 2-dimensionale, parametrische und optional polare Gleichungen. |
|||
⚫ | |||
==Description== |
|||
{{Caption|DrawParametric2DFunction}} |
|||
Draws 2-dimensional, parametric and optionally polar equations. |
|||
==Einschränkungen== |
|||
==Limitations== |
|||
Hat noch ein paar Fehler und vermisst einige Funktionen. Die Dokumentation befindet sich in den Dokumentenketten. |
|||
Still has some bugs and misses some features. Documentation is in the docstrings. |
|||
==Anwendung== |
|||
Art : |
|||
Beispielverwendung: |
|||
==Use== |
|||
Type : |
|||
⚫ | |||
#Example usage: |
|||
draw2Dfunction(xFunction="0.5*n", yFunction="-0.75*n", n=0, nd=-math.pi, step=50, pol=1) |
draw2Dfunction(xFunction="0.5*n", yFunction="-0.75*n", n=0, nd=-math.pi, step=50, pol=1) |
||
==Skript== |
|||
⚫ | |||
ToolBar Icon [[Image:Macro_Draw_Parametric_2D_Function.png]] |
|||
==Script== |
|||
'''Macro_drawParametric2DFunction.FCMacro''' |
'''Macro_drawParametric2DFunction.FCMacro''' |
||
{{Code|code= |
|||
⚫ | |||
import FreeCAD, FreeCADGui, Part |
import FreeCAD, FreeCADGui, Part |
||
Line 42: | Line 57: | ||
nStart=n |
nStart=n |
||
while math.fabs(n-nd)-1.0/step>0: |
while math.fabs(n-nd)-1.0/step>0: |
||
print "n: " + str(n) |
print( "n: " + str(n)) |
||
x=evalFunction(xFunction, n) |
x=evalFunction(xFunction, n) |
||
y=evalFunction(yFunction, n) |
y=evalFunction(yFunction, n) |
||
nNext=n+math.copysign(1,nd-n)/step |
nNext=n+math.copysign(1,nd-n)/step |
||
print "nNext: " + str(nNext) |
print( "nNext: " + str(nNext)) |
||
xNext=evalFunction(xFunction, nNext) |
xNext=evalFunction(xFunction, nNext) |
||
yNext=evalFunction(yFunction, nNext) |
yNext=evalFunction(yFunction, nNext) |
||
Line 53: | Line 68: | ||
else: |
else: |
||
nextSeg=(x*math.cos(y),x*math.sin(y),z),(xNext*math.cos(yNext),xNext*math.sin(yNext),z) |
nextSeg=(x*math.cos(y),x*math.sin(y),z),(xNext*math.cos(yNext),xNext*math.sin(yNext),z) |
||
print "nextSeg: " + str(nextSeg) |
print( "nextSeg: " + str(nextSeg)) |
||
nomme=Part.makeLine(*nextSeg) |
nomme=Part.makeLine(*nextSeg) |
||
if n==nStart: |
if n==nStart: |
||
Line 65: | Line 80: | ||
}} |
}} |
||
⚫ |
Latest revision as of 16:19, 2 August 2021
Beschreibung |
---|
Zeichnet 2-dimensionale, parametrische und optional polare Gleichungen. Versionsmakro : 1.0 Datum der letzten Änderung : 2012-08-30 FreeCAD version : All Herunterladen : ToolBar Icon Autor: T4b |
Autor |
T4b |
Herunterladen |
ToolBar Icon |
Links |
Makros Rezepte Wie installiere ich Makros So passen Sie Symbolleisten an |
Macro-Version |
1.0 |
Datum der letzten Änderung |
2012-08-30 |
FreeCAD-Version(s) |
All |
Standardverknüpfung |
None |
Siehe auch |
None |
Beschreibung
Zeichnet 2-dimensionale, parametrische und optional polare Gleichungen.
DrawParametric2DFunction
Einschränkungen
Hat noch ein paar Fehler und vermisst einige Funktionen. Die Dokumentation befindet sich in den Dokumentenketten.
Anwendung
Art :
Beispielverwendung:
draw2Dfunction(xFunction="0.5*n", yFunction="-0.75*n", n=0, nd=-math.pi, step=50, pol=1)
Skript
Macro_drawParametric2DFunction.FCMacro
import FreeCAD, FreeCADGui, Part import math def evalFunction(suppliedFunction, n): """This function uses eval to evaluate suppliedFunction. It does in no way check whether suppliedFunction is evil, thus it is itself evil! """ return eval(suppliedFunction) def draw2Dfunction(xFunction="n", yFunction="n", n=-5, nd=10, step=10, z=0, pol=0): """Draws 2-dimensional mathemathical functions The function is drawn for n's between n and n+nd, in steps of 1/step, on the z-coordinate z. Equations for x and y can be given (xFunction and yFunction arguments), they default to n. If pol=1 then x is interpreted as r and y is interpreted as t. """ nStart=n while math.fabs(n-nd)-1.0/step>0: print( "n: " + str(n)) x=evalFunction(xFunction, n) y=evalFunction(yFunction, n) nNext=n+math.copysign(1,nd-n)/step print( "nNext: " + str(nNext)) xNext=evalFunction(xFunction, nNext) yNext=evalFunction(yFunction, nNext) if pol==0: nextSeg=(x,y,z),(xNext,yNext,z) else: nextSeg=(x*math.cos(y),x*math.sin(y),z),(xNext*math.cos(yNext),xNext*math.sin(yNext),z) print( "nextSeg: " + str(nextSeg)) nomme=Part.makeLine(*nextSeg) if n==nStart: WWire=Part.Wire([nomme]) else: WWire=Part.Wire([WWire,nomme]) n=nNext Part.show(WWire) #Example usage: draw2Dfunction(xFunction="0.5*n", yFunction="-0.75*n", n=0, nd=-math.pi, step=50, pol=1)