Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

modeling a mathematical shape

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
dim678
2286 Views, 17 Replies

modeling a mathematical shape

dim678
Enthusiast
Enthusiast

how can i model such a plot in autocad.

this plot what created using a mathematical formula ,demostrated in mathlab.
thanks



Capture.JPGCapture2.JPG

0 Likes

modeling a mathematical shape

how can i model such a plot in autocad.

this plot what created using a mathematical formula ,demostrated in mathlab.
thanks



Capture.JPGCapture2.JPG

17 REPLIES 17
Message 2 of 18
Kent1Cooper
in reply to: dim678

Kent1Cooper
Consultant
Consultant

Welcome to these Forums!  [I saw this over at the CADFORUM.cz site.]

 

Can you post a link to the Mathlab web-page, so we can see what all the terms in that equation represent, and understand what the two curves of different colors are about?

Kent Cooper, AIA
0 Likes

Welcome to these Forums!  [I saw this over at the CADFORUM.cz site.]

 

Can you post a link to the Mathlab web-page, so we can see what all the terms in that equation represent, and understand what the two curves of different colors are about?

Kent Cooper, AIA
Message 3 of 18
john.vellek
in reply to: dim678

john.vellek
Alumni
Alumni

HI @dim678,

 

Obviously AutoCAD is not a mathematics modeling package. However, if there is a set of data points or other properties that you can provide perhaps there is a way to create a model of some value. Do you have such a dataset and an example of the type of output for which you are looking?


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes

HI @dim678,

 

Obviously AutoCAD is not a mathematics modeling package. However, if there is a set of data points or other properties that you can provide perhaps there is a way to create a model of some value. Do you have such a dataset and an example of the type of output for which you are looking?


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
Message 4 of 18
dim678
in reply to: Kent1Cooper

dim678
Enthusiast
Enthusiast

the colors have no meaning its just a contour

0 Likes

the colors have no meaning its just a contour

Message 5 of 18
dim678
in reply to: john.vellek

dim678
Enthusiast
Enthusiast

i have only the points of the contour

i would like to create a 3d of the shape with width og 1 mm

is there a way?

thanks 

0 Likes

i have only the points of the contour

i would like to create a 3d of the shape with width og 1 mm

is there a way?

thanks 

Message 6 of 18
pendean
in reply to: dim678

pendean
Community Legend
Community Legend
Can you post a link to the Mathlab web-page you are referencing?
0 Likes

Can you post a link to the Mathlab web-page you are referencing?
Message 7 of 18
Kent1Cooper
in reply to: dim678

Kent1Cooper
Consultant
Consultant

@yafimv wrote:

the colors have no meaning its just a contour


But it's two contours.  The colors are not what I was wondering about, but why there are two of them.  Do they represent running the same equation twice with different values for something in the equation?  I don't think they can both be part of one result from the same equation.  I'm assuming the 'r' is the radius out from the origin.  As you step outward in small increments of 'r', you get different angle results [phi], and that's what's doing the sweeping back and forth.  But it looks like that equation would give only one angle result for any value of 'r', but there's one location on each of the two curves for any given radius.  They look like they might be exactly the same shape except for the greenish extension off the outer end of the brownish one, but maybe they're slightly different..

 

So what's alpha?  What's R-sub-zero?  [The outermost radius limit?]  What's tau?  What's ln?  That last one may just be mathematical terminology for some function I haven't encountered, though it may be clear from the source, but the others look more definitely like variables you plug specific values into.  Presumably this shape is the result of a specific set of values for those, and with different values the resulting shape would be different.

 

That's why two of us have asked for a link to a web page, in hopes of answering these questions.  It might be comparatively simple to generate the same curve(s) in AutoCAD, along which you could Sweep or Extrude something, but not without those answers.

Kent Cooper, AIA
0 Likes


@yafimv wrote:

the colors have no meaning its just a contour


But it's two contours.  The colors are not what I was wondering about, but why there are two of them.  Do they represent running the same equation twice with different values for something in the equation?  I don't think they can both be part of one result from the same equation.  I'm assuming the 'r' is the radius out from the origin.  As you step outward in small increments of 'r', you get different angle results [phi], and that's what's doing the sweeping back and forth.  But it looks like that equation would give only one angle result for any value of 'r', but there's one location on each of the two curves for any given radius.  They look like they might be exactly the same shape except for the greenish extension off the outer end of the brownish one, but maybe they're slightly different..

 

So what's alpha?  What's R-sub-zero?  [The outermost radius limit?]  What's tau?  What's ln?  That last one may just be mathematical terminology for some function I haven't encountered, though it may be clear from the source, but the others look more definitely like variables you plug specific values into.  Presumably this shape is the result of a specific set of values for those, and with different values the resulting shape would be different.

 

That's why two of us have asked for a link to a web page, in hopes of answering these questions.  It might be comparatively simple to generate the same curve(s) in AutoCAD, along which you could Sweep or Extrude something, but not without those answers.

Kent Cooper, AIA
Message 8 of 18
dim678
in reply to: Kent1Cooper

dim678
Enthusiast
Enthusiast

Hello,answers to your question are as follows 
"Do they represent running the same equation twice with different values for something in the equation?"

each curve has a different formula but the input values are the same.

 

"So what's alpha?  What's R-sub-zero?  [The outermost radius limit?]  What's tau?  What's ln?"

 

ln is a logarithmic function , alpha and R  are just constants which i put in the formula,basickly"

 

basically i can get the polar coordinates of the contour,what should i do afterwards.

thanks

 

0 Likes

Hello,answers to your question are as follows 
"Do they represent running the same equation twice with different values for something in the equation?"

each curve has a different formula but the input values are the same.

 

"So what's alpha?  What's R-sub-zero?  [The outermost radius limit?]  What's tau?  What's ln?"

 

ln is a logarithmic function , alpha and R  are just constants which i put in the formula,basickly"

 

basically i can get the polar coordinates of the contour,what should i do afterwards.

thanks

 

Message 9 of 18
vladimir_michl
in reply to: dim678

vladimir_michl
Advisor
Advisor

You can use our 2DPLOT utility (see http://www.cadstudio.cz/en/apps/2dplot/). You equation then should be expressed in cartesian space (X/Y) - in LISP:

 
; for range (0-1.5>
(defun fPolar1 (u / r tau alfa R0)
;x = (* r (cos th))
;y = (* r (sin th))
 (setq r u)
 (setq tau 1.1) ; example
 (setq alfa 1.0) ; example
 (setq R0 0.1) ; example
 (setq th (* alfa (sin (/ (* pi (log (/ r R0))) (log tau))))) ; your expression
 (list (* r (cos th)) (* r (sin th))) ; return (X Y)
)
 
Then call (type):
 
(2Dplot fPolar1 0.001 1.5 0.001)
 
meaning - draw my function "fPolar1" from 0.001 to 1.5 (the radius), with ministeps of 0.001
 
This procedure and the example gives something like that:
 
fpolar1.png
 
 

You can use our 2DPLOT utility (see http://www.cadstudio.cz/en/apps/2dplot/). You equation then should be expressed in cartesian space (X/Y) - in LISP:

 
; for range (0-1.5>
(defun fPolar1 (u / r tau alfa R0)
;x = (* r (cos th))
;y = (* r (sin th))
 (setq r u)
 (setq tau 1.1) ; example
 (setq alfa 1.0) ; example
 (setq R0 0.1) ; example
 (setq th (* alfa (sin (/ (* pi (log (/ r R0))) (log tau))))) ; your expression
 (list (* r (cos th)) (* r (sin th))) ; return (X Y)
)
 
Then call (type):
 
(2Dplot fPolar1 0.001 1.5 0.001)
 
meaning - draw my function "fPolar1" from 0.001 to 1.5 (the radius), with ministeps of 0.001
 
This procedure and the example gives something like that:
 
fpolar1.png
 
 
Message 10 of 18
Kent1Cooper
in reply to: Kent1Cooper

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

... What's ln?  That last one may just be mathematical terminology for some function ....


Well, duh on me -- the natural log [I don't have any use for them often enough to have recognized it at first].

 

Since this is a fundamentally radially-oriented operation, it seems to me it's overkill to do it with a function that converts to X and Y coordinates.  It can more concisely be done with one that uses (polar):

 

(defun wavy (R0 inc alpha tau / r)
  (setq r 0)
  (setvar 'cmdecho 0)
  (command "_.spline" '(0 0 0))
  (repeat (fix (/ R0 inc))
    (command
      (polar
        '(0 0 0)
        (* alpha (sin (/ (* pi (log (/ (setq r (+ r inc)) R0))) (log tau))))
        r
      ); polar
    ); command
  ); repeat
  (command "" "" ""); conclude Spline
  (setvar 'cmdecho 1)
  (princ)
); defun

That long line is the conversion of the formula into AutoLisp terminology.  'R0' is the outermost extent, 'inc' is the size of the stepping increment in radius between calculated points in the Spline.  This is the result of using that with these arguments:

 

(wavy 1.5 0.001 1.0 1.4)

 

and looks pretty similar to [one of the curves in] the image:

 

wavy.png

 

I leave it to you to fine-tune the arguments to get a shape more precisely as you want it.  You can use a polar Array, or Copy it in place and Rotate one of them about 0,0, if you need two as in the original image.

Kent Cooper, AIA
0 Likes


@Kent1Cooper wrote:

... What's ln?  That last one may just be mathematical terminology for some function ....


Well, duh on me -- the natural log [I don't have any use for them often enough to have recognized it at first].

 

Since this is a fundamentally radially-oriented operation, it seems to me it's overkill to do it with a function that converts to X and Y coordinates.  It can more concisely be done with one that uses (polar):

 

(defun wavy (R0 inc alpha tau / r)
  (setq r 0)
  (setvar 'cmdecho 0)
  (command "_.spline" '(0 0 0))
  (repeat (fix (/ R0 inc))
    (command
      (polar
        '(0 0 0)
        (* alpha (sin (/ (* pi (log (/ (setq r (+ r inc)) R0))) (log tau))))
        r
      ); polar
    ); command
  ); repeat
  (command "" "" ""); conclude Spline
  (setvar 'cmdecho 1)
  (princ)
); defun

That long line is the conversion of the formula into AutoLisp terminology.  'R0' is the outermost extent, 'inc' is the size of the stepping increment in radius between calculated points in the Spline.  This is the result of using that with these arguments:

 

(wavy 1.5 0.001 1.0 1.4)

 

and looks pretty similar to [one of the curves in] the image:

 

wavy.png

 

I leave it to you to fine-tune the arguments to get a shape more precisely as you want it.  You can use a polar Array, or Copy it in place and Rotate one of them about 0,0, if you need two as in the original image.

Kent Cooper, AIA
Message 11 of 18
dim678
in reply to: Kent1Cooper

dim678
Enthusiast
Enthusiast

so after plotting this how can  created a shifted version by a certain angle and afterward to  add a width of 1 mm.

 

thanks 

0 Likes

so after plotting this how can  created a shifted version by a certain angle and afterward to  add a width of 1 mm.

 

thanks 

Message 12 of 18
Kent1Cooper
in reply to: dim678

Kent1Cooper
Consultant
Consultant
Accepted solution

@yafimv wrote:

so after plotting this how can  created a shifted version by a certain angle and afterward to  add a width of 1 mm. ....


I edited my Reply, perhaps after you saw it, with a description of two ways to get two of them.  If you want to apply width, Splines can't do that, but Polylines can.  With as small a radius increment as I used, you probably wouldn't be able to tell the different in smoothness even if the Polyline is made up of only line segments.  Change this line:

 

(command "_.spline" '(0 0 0))

 

to this:

 

(command "_.pline" '(0 0 0))


and this line:

 

(command "" "" ""); conclude Spline

 

to this:

 

(command ""); conclude Pline

 

If you use a larger increment / fewer segments, you could use PEDIT on the resulting Polyline, and its Spline-curve option, to smooth out the curvature, and it would still be able to have width.

Kent Cooper, AIA
0 Likes


@yafimv wrote:

so after plotting this how can  created a shifted version by a certain angle and afterward to  add a width of 1 mm. ....


I edited my Reply, perhaps after you saw it, with a description of two ways to get two of them.  If you want to apply width, Splines can't do that, but Polylines can.  With as small a radius increment as I used, you probably wouldn't be able to tell the different in smoothness even if the Polyline is made up of only line segments.  Change this line:

 

(command "_.spline" '(0 0 0))

 

to this:

 

(command "_.pline" '(0 0 0))


and this line:

 

(command "" "" ""); conclude Spline

 

to this:

 

(command ""); conclude Pline

 

If you use a larger increment / fewer segments, you could use PEDIT on the resulting Polyline, and its Spline-curve option, to smooth out the curvature, and it would still be able to have width.

Kent Cooper, AIA
Message 13 of 18
dim678
in reply to: Kent1Cooper

dim678
Enthusiast
Enthusiast

i have inserted the following code  and saved .

when i loaded it and wrote the name of the file ,it said unknown command,

what am i missing?

 

thanks
Capture.JPG

0 Likes

i have inserted the following code  and saved .

when i loaded it and wrote the name of the file ,it said unknown command,

what am i missing?

 

thanks
Capture.JPG

Message 14 of 18
Kent1Cooper
in reply to: dim678

Kent1Cooper
Consultant
Consultant

@yafimv wrote:

....

when i loaded it and wrote the name of the file ,it said unknown command,

what am i missing?

 

....

It's not a command definition, it's a function with arguments.  You use it as in Post 10, in parentheses with the arguments included.

 

If you prefer, it could be altered easily to make it a command, which would prompt the User for the values, so that you don't have to define a different command for every set of values you might ever want [that's why I did it in the function-with-arguments approach -- it's much easier to use with different values, so you can tweak them to get the best result].

Kent Cooper, AIA
0 Likes


@yafimv wrote:

....

when i loaded it and wrote the name of the file ,it said unknown command,

what am i missing?

 

....

It's not a command definition, it's a function with arguments.  You use it as in Post 10, in parentheses with the arguments included.

 

If you prefer, it could be altered easily to make it a command, which would prompt the User for the values, so that you don't have to define a different command for every set of values you might ever want [that's why I did it in the function-with-arguments approach -- it's much easier to use with different values, so you can tweak them to get the best result].

Kent Cooper, AIA
Message 15 of 18
dim678
in reply to: Kent1Cooper

dim678
Enthusiast
Enthusiast

i am trying to see where to go in the interface of auto cad to run this function(attached the photos of the CAD menu bellow),could where in the menus to go?

thanks

 

 

0 Likes

i am trying to see where to go in the interface of auto cad to run this function(attached the photos of the CAD menu bellow),could where in the menus to go?

thanks

 

 

Message 16 of 18
dim678
in reply to: vladimir_michl

dim678
Enthusiast
Enthusiast

Hello Vladimir, could you say in what menu should(photo attached bellow) i go in order to run this fntion,

because i went to "Visual LISP editor" and saved the code as a lisp file and load it

but when i run the file name ,it say that its not recognized.

if you could help we with running it

 

Thanks

0 Likes

Hello Vladimir, could you say in what menu should(photo attached bellow) i go in order to run this fntion,

because i went to "Visual LISP editor" and saved the code as a lisp file and load it

but when i run the file name ,it say that its not recognized.

if you could help we with running it

 

Thanks

Message 17 of 18
Kent1Cooper
in reply to: dim678

Kent1Cooper
Consultant
Consultant

@yafimv wrote:

i am trying to see where to go in the interface of auto cad to run this function....


Save the code to a .lsp file in some known location [it looks like you have already done that].  Type APPLOAD, navigate to that file, and Load it.  Use it as shown before.

 

If you want it to be loaded automatically in every drawing you open, add a line like this to your acaddoc.lsp file:

 

(load "YourFileName")

 

[you don't need to include the .lsp filetype ending, but you can if you want to].

 

If you don't have an acaddoc.lsp file yet, make one, even if that's the only thing in it, and put it in some location that's in the Support File Search Path list in the Files tab in OPTIONS.

Kent Cooper, AIA
0 Likes


@yafimv wrote:

i am trying to see where to go in the interface of auto cad to run this function....


Save the code to a .lsp file in some known location [it looks like you have already done that].  Type APPLOAD, navigate to that file, and Load it.  Use it as shown before.

 

If you want it to be loaded automatically in every drawing you open, add a line like this to your acaddoc.lsp file:

 

(load "YourFileName")

 

[you don't need to include the .lsp filetype ending, but you can if you want to].

 

If you don't have an acaddoc.lsp file yet, make one, even if that's the only thing in it, and put it in some location that's in the Support File Search Path list in the Files tab in OPTIONS.

Kent Cooper, AIA
Message 18 of 18
vladimir_michl
in reply to: dim678

vladimir_michl
Advisor
Advisor

You don't have to bother with the VisualLISP editor. Just take the supplied code and copy it (Ctrl+C/Ctrl+V) to your AutoCAD command line or save it to a .LSP file, edit (e.g. in Notepad) it as neccessary and load it into AutoCAD with the APPLOAD command.

 

The 2DPlot utility makes LWPOLYLINEs so you can add width easily by changing the Lightweight property in the polyline properties (Ctrl+1).

 

You can also spice up the output by superimposing the resulting shape on an automatically generated radial grid from another freeware add-on - the DrGrid utility - see http://www.cadforum.cz/cadforum_en/drgrid-parametric-grid-for-autocad-drawings-tip9829 - like this:

 

drgrid.png

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz

 

 

You don't have to bother with the VisualLISP editor. Just take the supplied code and copy it (Ctrl+C/Ctrl+V) to your AutoCAD command line or save it to a .LSP file, edit (e.g. in Notepad) it as neccessary and load it into AutoCAD with the APPLOAD command.

 

The 2DPlot utility makes LWPOLYLINEs so you can add width easily by changing the Lightweight property in the polyline properties (Ctrl+1).

 

You can also spice up the output by superimposing the resulting shape on an automatically generated radial grid from another freeware add-on - the DrGrid utility - see http://www.cadforum.cz/cadforum_en/drgrid-parametric-grid-for-autocad-drawings-tip9829 - like this:

 

drgrid.png

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report