Jump to content

How to draw an algebraic equation


Recommended Posts

For example y=(x^2)sin(x^0.5)

Is there a way to input it into aotocad, or at least connect the drawing with an excel sheet from which i can extract (x,y) points?

Link to comment
Share on other sites

How about something like this lisp function?

 

(defun c:foo ( / x y)  
  (setq x 0.5)
  (repeat 22     
    (setq y (* (* x x) (sin (expt x 0.5))))    
    (vl-cmdf "point" (list x y))
    (setq x (+ x 0.5))
  )
)

 

  • Like 1
Link to comment
Share on other sites

Good idea but i don't know much lisp

Also in what language is vl-cmdf, and is there a lisp function to create a point instead of learning a new and other language?

And also is there a method to select all the points together when i make a spline, or do i have to pick them one by one?

Edited by KarolR
Link to comment
Share on other sites

You don't have to know any, in order to run this function. Even so, it's not difficult to pick it up.

 

I added a function to draw the spline, found here. If you don't want to draw the points you can comment out that line with a semicolon.

 

 

(defun myspline ( arg)
  (command "_SPLINE")              ;start the command
  (foreach thePoint arg            ;parse points list
    (command thePoint)
  )
  (command "" "" "")               ;accept default tangents & end the command
)  

(defun c:foo ( / x y)  
  (setq x 0.5 new '())
  (repeat 22     
    (setq y (* (* x x) (sin (expt x 0.5))))    
    (vl-cmdf "point" (list x y))
    (setq new (cons (list x y) new))
    (setq x (+ x 0.5))
  )
  (myspline new)
)

 

Link to comment
Share on other sites

You could compare the three they are the same thing used to make something

 

(command 

(entmake

(vl-cmdf

 

There is a difference in the way they work an entmake is generally faster than a command but requires more lines of code

 

You may also want to turn on the points so you can see them use "ptype"

 

A few more comments

 



(defun myspline ( arg)             ; a function called myspline passed a variable value to it arg    
  (command "_SPLINE")              ; start the command spline
  (foreach thePoint arg            ; parse points list foreach loops through the list of points in arg
    (command thePoint)             ; create an acad point the point has x & y values
  )
  (command "" "" "")               ; accept default tangents & end the command
)  

(defun c:foo ( / x y)       ; a function foo with local variables x & y
  (setq x 0.5 new '())      ; set x to 0.5 and make a list of points new but set to empty
  (repeat 22                ; do it 22 times
    (setq y (* (* x x) (sin (expt x 0.5))))    ; the forumla
    (vl-cmdf "point" (list x y))               ; draw an acad point
    (setq new (cons (list x y) new))           ; add the x y of the points to the list new
    (setq x (+ x 0.5))                         ; increase x by 0.5
  )
  (setvar 'pdmode 35)      ; turn on the points so you can see them and set style
  (setvar 'pdsize 0)       ; size of the point use ptype to see other information
  (myspline new)           ; call the defun myspline and pass it the list of points new 
)
Link to comment
Share on other sites

Often, the use of a trigonometric function implies polar graphing.  If that were the case, and I limited the evaluation interval between 0 and 2PI, the Sin(SQRT(x)) never reaches the negative zone.  In other words, with just one complete turn, the polar value of y never decreases.  The function would graph to something like this:

PolarFunction.png.d3046c060e8333638b36e98e2a4d16a9.png

Link to comment
Share on other sites

In the following Excel sheet B2 contains your equation:

       =(A2^2)*SIN(A2^0.5) ]

and C2 has  

    =CONCATENATE(A2,",",B2)

Copy cells C2 through the end value of column C to the Windows clipboard (Ctrl-C).

 

Then in AutoCAD give the pline command and do a paste (Ctrl-V)

image.png.079794810e189925c59efc47271d9cbb.png

Edited by lrm
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...