Jump to content

Drawing Sine/Cosine Waves, Any thoughts?


harrison-matt

Recommended Posts

All,

 

Before i start bashing my head on the desk reverting back to old trig, is there anywone with neat suggestions to drawing a cosine wave between two points?

 

:)

 

Matt

Link to comment
Share on other sites

Use the getint, getpoint (with an (initget 32) twist), distance, angle, and polar functions..?

 

Oh! And for kicks, throw in a little lambda+mapcar combo on the side (to handle any curve frequency). :wink:

Link to comment
Share on other sites

I like this function however, I am really trying to find out how to draw one by specifying two points.

The ratio of Period to Amp i am looking forward is 2:0.5

and i would like to be able to specify the Amp

Link to comment
Share on other sites

I like this function however, I am really trying to find out how to draw one by specifying two points.

The ratio of Period to Amp i am looking forward is 2:0.5

and i would like to be able to specify the Amp

 

See post #3.

Link to comment
Share on other sites

 (initget 7)
 (setq amp (getdist "\nAmplatude:   "))
 (initget 7)
 (setq frq (getdist "\nFrequency:   "))
 (initget 6)
 (setq rep (getint "\n# of Points per Wave <1000>:   "))
 (and (not rep)
      (setq rep 1000))
 (setq i 0
     inc (/ (* 2 pi) rep))
 (command "_.PLINE")
 (repeat (1+ rep)
     (command (list (* i frq) (* amp (sin i))))
     (setq i (+ i inc)))
 (command "")

 

 

-David

Link to comment
Share on other sites

Another 'fun' one :P

 

(defun c:DynFun ( / _GenerateFunctionPoints fun p1 gr )
 ;; © Lee Mac 2010

 ;; Function to evaluate
 (setq fun sin)

 (defun _GenerateFunctionPoints ( p1 p2 / d a1 a2 i j )
   (setq d (distance p1 p2) a1 (angle p1 p2) a2 (+ a1 (/ pi 2.)) i 0 p3 (polar p1 a2 (fun 0.)))

   (while (<= (setq x (* 0.1 (setq i (1+ i)))) d)
     (grdraw p3 (setq p3 (polar (polar p1 a1 x) a2 (fun x))) 3)
   )
 )

 (if (setq p1 (getpoint "\nSpecify First Point: "))
   (while (= 5 (car (setq gr (grread 't 13 0)))) (redraw)
     (_GenerateFunctionPoints p1 (cadr gr))
   )
 )
 
 (princ)
)

Could work with any function :)

 

SineWave.gif

 

I like this one :)

 

(setq fun (lambda ( x ) (* (sin (* 2.0 x)) (exp (/ x 10.0)))))

Link to comment
Share on other sites

Lee,

 

That is really cool! Grread is pretty sweet! i'll keep trying on my end and will post my attempts and errors here.

 

David, thanks for the tips.

 

Thanks,

Matt

Link to comment
Share on other sites

That is really cool! Grread is pretty sweet! i'll keep trying on my end and will post my attempts and errors here.

 

Grread is great for visual effect, but useless for practical applications as you have no OSnap, Ortho, Tracking or any other standard functionality. GrRead is purely for tracking keystrokes, mouse movements - general user input. Any OSnap or other functionality must be imitated within the grread loop.

 

Lee

Link to comment
Share on other sites

  • 1 year later...

This is awosome and exactly what i want, drawing sin wave controlling amplitude decreasing increasing i am doing some FEA project

 

but life cant be awsome like that always cause i got this error

 

SINECURVE - Error: quit / exit abort

SYSTEM VARIABLES have been reset

 

i googled the system variables thing but never got an answer beside the original forum is closed down and i cant get to Tony the man how come up with it ....please if any one know any thing on how to fix this error in 2011 i would really appreciated

 

I am attaching the files for the SINCURVE function if you can do anything to fix the errors please

0305.lsp

0305alspsol-sinecurve.dcl

Link to comment
Share on other sites

Here, I've corrected error (it was name of *.dcl - you should not rename file as it was written - should be sinecurve.dcl)... Anyway, I've incorporated dcl into lsp and you don't have to store it in support search path of ACAD - you can load it from anywhere - it should work - creates temp dcl file, use that dcl and at the end removes temp dcl...

 

Regards, M.R.;)

sinecurve.lsp

Link to comment
Share on other sites

  • 8 years later...

I know this is a super old topic, but I've been looking for something like this.

 

I ended up coming to my own solution for parametric sine/cosine waves using contiguous ellipse arcs with an apparatus of parametric construction geometry to define osnaps for each axis of the unit arc.

 

However the only parameters I could figure out to create, and which I think might exist with a setup like this, are the amplitude and frequency - no damping or anything like that.

 

Additionally I just came across this: https://www.cadstudio.cz/en/apps/2dplot/, which looks like it might be really for providing appropriate fidelity and additional parameters such as damping.

sine_generator.PNG

sine_generator.dwg

Edited by raed
not quadrants
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...