Re: Math.cos() problems
- From: Brandon McCombs <none@xxxxxxxx>
- Date: Fri, 07 Dec 2007 00:01:48 -0500
Knute Johnson wrote:
Brandon McCombs wrote:
Hello,
I'm trying to do something simple but Java turns it into a federal
case. All I want to do is draw a couple circles on a Graphics2D
canvas with one movable and attracted to the 2nd one which is
stationary. Basically I'm just trying to get basic functionality
working that simulates gravitational attraction between the spheres.
I had everything working concerning the movement calculations (force,
acceleration, velocity) up to the point of performing the calculation
that would generate each new pixel positions for the circle that I am
allowing to move. I ran into problems because I had to determine the
angle between the moving circle and the stationary one and use the
angle in the equations x = rCos(angle) and y = rSin(angle) so I could
determine how much the movable circle should move.
The problem is that I have no clue how Java is calculating the cosine
and xine of the angle I calculate (even calculating the angle is a
chore which may be confusing the problem even further). With respect
to what screen location are the trig functions being evaluated? (0,0)
on the drawing canvas? Does it matter? I thought it did especially
since my angle is based on the location of one of my circles and it
isn't at 0,0 on the canvas. Where am I going wrong? This is
frustrating. If you need more info let me know.
thanks
Could it be that you are getting messed up because they y axis is upside
down? Add pi to your angle before calculating.
Well that was one problem I noticed last night after I posted. I'm doing
other stuff that I shouldn't be but I haven't had time to fix it yet.
When I simplify the code I may end up with it working properly. I'm
aware of -pi/2 and pi/2 as the range for cosine although whether I was
correctly taking that into account last night is another issue. I'm also
aware that the java methods use radians for input/output which I've been
correctly taking into account. It's been a while since I did a lot of
trig stuff though. I'll try again when I have time. thanks guys
.
Relevant Pages
- Re: Math.cos() problems
... I had everything working concerning the movement calculations up to the point of performing the calculation that would generate each new pixel positions for the circle that I am allowing to move. ... I ran into problems because I had to determine the angle between the moving circle and the stationary one and use the angle in the equations x = rCosand y = rSinso I could determine how much the movable circle should move. ... The problem is that I have no clue how Java is calculating the cosine and xine of the angle I calculate. ... Math.cos, Math.sin, and Math.atan2 deal with radians. ... (comp.lang.java.programmer) - Re: Math.cos() problems
... I had everything working concerning the movement calculations up to the point of performing the calculation that would generate each new pixel positions for the circle that I am allowing to move. ... I ran into problems because I had to determine the angle between the moving circle and the stationary one and use the angle in the equations x = rCosand y = rSinso I could determine how much the movable circle should move. ... The problem is that I have no clue how Java is calculating the cosine and xine of the angle I calculate. ... (comp.lang.java.programmer) - Re: Math.cos() problems
... I'm trying to do something simple but Java turns it into a federal case. ... I had everything working concerning the movement calculations up to the point of performing the calculation that would generate each new pixel positions for the circle that I am allowing to move. ... I ran into problems because I had to determine the angle between the moving circle and the stationary one and use the angle in the equations x = rCosand y = rSinso I could determine how much the movable circle should move. ... The problem is that I have no clue how Java is calculating the cosine and xine of the angle I calculate. ... (comp.lang.java.programmer) - Math.cos() problems
... I'm trying to do something simple but Java turns it into a federal case. ... I had everything working concerning the movement calculations up to the point of performing the calculation that would generate each new pixel positions for the circle that I am allowing to move. ... I ran into problems because I had to determine the angle between the moving circle and the stationary one and use the angle in the equations x = rCosand y = rSinso I could determine how much the movable circle should move. ... The problem is that I have no clue how Java is calculating the cosine and xine of the angle I calculate. ... (comp.lang.java.programmer) - Re: Mr. PV teaches jb spreadsheet geometry (Re: Garlics contouring article
... Placing the insert's edge length of .600 in A122, the vertex angle in I122, ... you want the em to move *just as it would in cutter comp*. ... Nowhere on the spreadsheet do you see the actual coordinates of the vertices ... the circle dropped in the 60 deg V, and flipping it 180 deg around the chord ... (alt.machines.cnc) |
|