How to draw a mathmatical function?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
smilie
Posts: 10
Joined: Sat Dec 07, 2013 7:37 am

How to draw a mathmatical function?

Post by smilie »

Dear peoples,

how can i draw a mathematical functions?
I want to draw y=x²/4 and i need to set some drillings depending of this function.

Any ideas?
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: How to draw a mathmatical function?

Post by wmayer »

Check out this link. Since arbitrary parametric curves are not supported this solution does an approximation with line segments (simple) or B-spline curves.

viewtopic.php?f=13&t=6226#p50611
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: How to draw a mathmatical function?

Post by shoogen »

smilie wrote:I want to draw y=x²/4
Our geometry kernel support parabolas, so there should be no need to use an approximation
http://opencascade.sourcearchive.com/do ... abola.html
the default Parabola seems to have the right scaling and position, but is symetrical to the x-axis.

Code: Select all

import FreeCAD
import Part
p=Part.Parabola
#p.Focal=1.0
p.rotate(FreeCAD.Placement(FreeCAD.Vector(),FreeCAD.Rotation(90,0,0)))
But haven't figured out yet, how to add limits.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: How to draw a mathmatical function?

Post by jmaustpc »

Hyperbola is there as well.
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: How to draw a mathmatical function?

Post by wmayer »

Our geometry kernel support parabolas, so there should be no need to use an approximation
The parabolas are handled the geometric way so that converting the algebraic form y=x²/4 is not that easy. Besides that when using a B-Spline curve of degree two then it's not an approximation but 100% exact.
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: How to draw a mathmatical function?

Post by shoogen »

wmayer wrote:
Our geometry kernel support parabolas, so there should be no need to use an approximation
The parabolas are handled the geometric way so that converting the algebraic form y=x²/4 is not that easy.
Why? I thought that i just need to set XDir to (0,1,0), YDir(1,0,0) and i would change Axis to (0,0,-1) to keep orientation right handed. The focal length (F) defaults to 1.0

Code: Select all

The Geom_Parabola parabola is parameterized as follows:
P(U) = O + U*U/(4.*F)*XDir + U*YDir 
wmayer wrote:Besides that when using a B-Spline curve of degree two then it's not an approximation but 100% exact.
That is true for parabolas, but not for the hyperbolas jmaustpc mentioned in the meantime. And getting the 100% exact B-Spline representation is not obivous to me. (I wouldn't trust the OCCT interpolation functions on this).
Post Reply