3D part from mathematical formula

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
rje106
Posts: 2
Joined: Fri Dec 22, 2017 11:38 pm

3D part from mathematical formula

Post by rje106 »

Hello All.

I hope that I've put this request in the correct place.

I'm beginning a new project to create some acoustic horns, which are defined by an equation which allows me to calculate the width based upon the height (Z relative to the mouth at Z-0). Ideally I'd like to work in spherical polar coordinates but I can happily convert the equations to polar if that's what's required.

I've done some searching but so far i haven't managed to find any examples of how I can create a sketch or solid based upon an equation.

Is this possible? and if so can anybody provide me with either a link to an example or details of how i should proceed? I'm happy to expand upon the details of the kind of shape I need to produce if that would be of help.

Thanks

Russell
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: 3D part from methematical formula

Post by bejant »

Hi Russel, and welcome! The trick is to know what phrases to use in your search. For your use case I think you will want to make use of the SpreadSheet WB, and use Expressions in the Sketcher WB so you an use the value of a cell as the numeral in a Constraint.

https://www.freecadweb.org/wiki/index.p ... _Workbench

https://www.youtube.com/watch?v=b07qbhYHZbU
https://www.youtube.com/watch?v=-HRDcCL73lM
https://www.youtube.com/watch?v=9DzpRqTvdU4

I think someone (maybe @DeepSOIC ?) has already done that to create an acoustic horn, but I can't find it...
User avatar
Willem
Veteran
Posts: 1852
Joined: Fri Aug 12, 2016 3:27 pm
Location: Lisse, The Netherlands

Re: 3D part from methematical formula

Post by Willem »

Hi, I could find the thread about the horn https://forum.freecadweb.org/viewtopic.php?t=14663, but unfortunately the file is not any more in Dropbox
mario52
Veteran
Posts: 4682
Joined: Wed May 16, 2012 2:13 pm

Re: 3D part from methematical formula

Post by mario52 »

hi

for equation tray Macro_WorkFeatures menu Wires > Curves and surface > Launch curves and surface menu

and Macros_recipes section Image mathematical functions

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: 3D part from methematical formula

Post by DeepSOIC »

bejant wrote: Sat Dec 23, 2017 5:43 am I think someone (maybe @DeepSOIC ?) has already done that to create an acoustic horn, but I can't find it...
Yep that was me!
https://forum.freecadweb.org/viewtopic.php?f=24&t=7822
I made an approximate tractrix by using a geometric method of construction, no formulas were involved.

I was happy with everything about it except for the actual sound :lol:


There are macros in Macros recipes that let one generate a curve by typing in parametric equations. Use them as basis for your solid.
rje106
Posts: 2
Joined: Fri Dec 22, 2017 11:38 pm

Re: 3D part from methematical formula

Post by rje106 »

Thanks all.

I'll have to do some reading and watching to try and work out how best to attack the problem. I had come across the spreadsheet functionality during my searched by concluded that it probably wasn't what I needed.

I'm trying to produce something like this

Image

Whilst I was sure that I could create the basic shape using a sketch of some form I've only ever used rotations and extrusions from a sketch. whereas what i need to produce while symmetrical has a different dimension down the X to the Y axis and thus couldn't be created using a rotation.

As I say I'll have a proper read and come back once I feel I'm properly informed on what's ben suggested so far.

Thanks again

Russell
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: 3D part from mathematical formula

Post by DeepSOIC »

rje106 wrote: Sat Dec 23, 2017 2:44 pm different dimension down the X to the Y axis and thus couldn't be created using a rotation.
Then, you can use Part Loft. It will take quite a bit more work of course, compared to a simple revolution.

Also, you can consider non-uniform scaling to squeeze a revolved shape to become more elliptical.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: 3D part from mathematical formula

Post by NormandC »

DeepSOIC wrote: Sat Dec 23, 2017 7:02 pm Also, you can consider non-uniform scaling to squeeze a revolved shape to become more elliptical.
You can obtain non-uniform scaling with a Draft Clone.
User avatar
thomas-neemann
Veteran
Posts: 11858
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: 3D part from mathematical formula

Post by thomas-neemann »

in the event that further suggestions are sought, here is a suggestion for a macro


https://www.youtube.com/watch?v=HMY3Ki1iatM


phpBB [video]





edit

Code: Select all

import FreeCAD
import Draft
import math


for r in range(5, 360,10):
     for t in range(0, 360,10):
          Draft.makePoint(r*math.cos(t*0.017452)*0.1, r*math.sin(r*0.017452)*0.1, r*math.sin(t*0.017452)*0.1)
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
mrdic
Posts: 132
Joined: Wed May 10, 2017 4:25 am

Re: 3D part from mathematical formula

Post by mrdic »

FormZ has an interesting closed rotational loft facility that's continuously tangential through the first profile, which is also the last profile. For other loft systems like FreeCAD, we get the same result by lofting through circles in the other direction to make a cylinder, tube or truncated cone. Which is how you can loft your horn, with circles or ellipses or rectangles with custom fillets in either the profiles or in the solid or surface result. I think
that offset will work painlessly with it too.
Post Reply