Results 1 to 20 of 48
Thread: sine wave in java2D graphics.
 02062012, 11:10 AM #1Member
 Join Date
 Jan 2012
 Posts
 5
 Rep Power
 0
sine wave in java2D graphics.
Hi i m new to Java 2D. i want to draw a sine wave based on the given frequency and amplitude of user input. Pls can anybody help me how to draw sine wave using 2D. i ve tried many sites , but i found only the programs which draws the sine wave based on the default height and width of the frame.Pls help me...
Thanks in advance....
 02062012, 02:47 PM #2
Re: sine wave in java2D graphics.
Sounds like you're trying to build the top floor of a building without anything under it, not even a foundation.
Learn Java Graphics.
Trail: 2D Graphics (The Java™ Tutorials)
Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
 02292012, 01:11 PM #3
Re: sine wave in java2D graphics.
hi,
I need to write a sine wave program for my project work of my final year engineering
Could you give me a sine wave program which can draw sine waves for given values, my sample value file is a ".dat" format with 10,000 values of x an y in two fields.
thanks in advance
 02292012, 02:24 PM #4
Re: sine wave in java2D graphics.
search in google for: java sinus graphics
 02292012, 02:27 PM #5
Re: sine wave in java2D graphics.
thx for the link

Re: sine wave in java2D graphics.
 02292012, 03:17 PM #7
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,231
 Blog Entries
 7
 Rep Power
 24
Re: sine wave in java2D graphics.
Wat happened to your brains? For a set of points (x,y) in the domain D and codomain C where D is [Dmin, Dmax] and C is [Cmin, Cmax], the points can be scaled as follows: x'= (xDmin)/(DmaxDmin) and
y' = (yCmin)/(CmaxCmin); the points (x',y') are in the domain and codomain [0, 1]. If a window component has the ranges [SXmin, SXmax] and [SYmin, SYmax] the points (x',y') can be scaled to those ranges:
Xs=x'*(SXmaxSXmin)+SXmin and Ys= y'*(SYmaxSYmin)+SYmin; the points (Xs,Ys) all are in the visible part of the window component.
kind regards,
JosThe only person who got everything done by Friday was Robinson Crusoe.
 02292012, 04:12 PM #8Moderator
 Join Date
 Apr 2009
 Posts
 12,709
 Rep Power
 22
Re: sine wave in java2D graphics.
Ow.
You broke my brain...Please do not ask for code as refusal often offends.
** This space for rent **
 02292012, 04:25 PM #9
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,231
 Blog Entries
 7
 Rep Power
 24
Re: sine wave in java2D graphics.
Oh dear; just for the record: the explanation is much longer than the code itself. Are computer folks allergic to a bit of math? It doesn't bite and can be quite useful most of the time (see this entire thread for a silly example).
kind regards,
JosThe only person who got everything done by Friday was Robinson Crusoe.
 03042012, 04:02 PM #10
 03042012, 04:29 PM #11
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,231
 Blog Entries
 7
 Rep Power
 24
Re: sine wave in java2D graphics.
If you want to plot/draw, say, f(x) = sin(x) for a single period the the domain D is the range [0, 2*pi] and the codomain is the interval [1, 1]; all points x, y are in the intervals DxC. My previous reply showed how to scale those values to other intervals (e.g. screen coordinates).
kind regards,
JosThe only person who got everything done by Friday was Robinson Crusoe.
 03042012, 04:35 PM #12

Re: sine wave in java2D graphics.
I think you want the cubic one not the quadratic one?
CubicCurve2D.Double (Java 2 Platform SE v1.4.2)Last edited by ozzyman; 03042012 at 04:49 PM.
 03042012, 04:48 PM #14
 03042012, 04:49 PM #15
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,231
 Blog Entries
 7
 Rep Power
 24

Re: sine wave in java2D graphics.
I added a link to the java doc.
 03042012, 04:52 PM #17
 03042012, 04:57 PM #18
 03042012, 05:11 PM #19
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,231
 Blog Entries
 7
 Rep Power
 24
 03042012, 05:16 PM #20
Similar Threads

Do number series represent sine wave?
By rng in forum New To JavaReplies: 12Last Post: 01182012, 04:46 PM 
sine and cosine
By Dennis in forum Advanced JavaReplies: 9Last Post: 11132010, 06:45 AM 
Java2D
By Alex j in forum Java 2DReplies: 1Last Post: 04072009, 04:59 PM 
Drawing the sine curve
By bumblyb33 in forum Java 2DReplies: 7Last Post: 03262009, 11:29 PM 
Demonstration of drawing points. It draws a sine wave
By Java Tip in forum SWT TipsReplies: 0Last Post: 06282008, 09:25 PM
Bookmarks