Damien Sky wrote:It is x (the xcoordinate of the point on the circle) that is decreasing by 0.1.
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
...incrementing a double by 0.1 is a notorious example of the imprecision of floating‑point arithmetic...
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:Now, ignore all the helpful tips you've gotten here about the Math class for the moment (and about coordinates being two numbers [Winston, where did you get that idea? ]).
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Stevens Miller wrote:Now, ignore all the helpful tips you've gotten here about the Math class for the moment (and about coordinates being two numbers [Winston, where did you get that idea? ]).
Erm, from Maps? Wiki admittedly says that it can be "one or more"; but I can't see how that would work for a circle (which is a 2D shape) without an agreed centre, radius and "North". And even then, wouldn't it simply be a "bearing" or angle?
I know I'm not a Maths expert, but please tell me where I've gone wrong.
Winston
a coordinate involves two numbers.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:A coordinate is a single number.
An xcoordinate and a ycoordinate are each a single number. Together, in the xyplane, they are a pair of coordinates that identify a unique point in the plane. More generally, any number of coordinates can identify a unique point in any ndimensional space.
There are some boringly complicating extensions to this: for example, a lot of code behind 3D graphics is written to handle fourcoordinate vectors of "homogenous" coordinates, in the form of [x, y, z, w], where the point in 3space is identified by the three coordinates (x/w, y/w, z/w). Believe it or not, this actually simplifies perspective transformations, since a fourcoordinate vector can be multiplied by a 4x4 matrix, which can contain any number of rotations, translations, enlargements, and perspective transforms, all composited upon one another, to put a canonical object into a 3D scene.
Damien is trying to compute the ycoordinate of a circle as a function defined on a range of xcoordinate values (actually, since circles aren't functions along any axis in the cartesian plane, he's correctly computing pairs of ycoordinates from each xcoordinate...
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Damien Sky wrote:I created a double "increment" and changed the code to this:
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
I hate signatures!
"Il y a peu de choses qui me soient impossibles..."
I hate signatures!
Winston Gutkowski wrote:Oh, OK. So if, for sake of argument, x = 1.0 is the "top" of the circle, he wants to know the y values as he goes linearly down the x axis in steps of 0.1 to 0, which can then be mirrored for the lower half of the semicircle.
Now I get it (I think). Tell me if I'm wrong.
Winston
"Il y a peu de choses qui me soient impossibles..."
Piet Souris wrote:In principle I agree. However, seeing that after your long reply, the discussion went
from homogenous coordinates to stop coding, I thought that a shortcut could
speed up things. Well, I wonder what OP has to say.
"Il y a peu de choses qui me soient impossibles..."
Hahahahahahaha! Do you have to hold a Colt .45 as you say that?Stevens Miller wrote: . . . "keep your hands where I can see them and step away from the mouse" . . .
Or maybe that two's complement arithmetic and IEEE 754 numbers were well‑known before Java was developed and they took it for granted people knew how binary arithmetic works?Today, Java's philosophy, that native types must be opaque, seems somewhat in conflict with knowing why integer types are (within their ranges) always exact, but floating types cannot be similarly trusted. . . .
Campbell Ritchie wrote:
Hahahahahahaha! Do you have to hold a Colt .45 as you say that?Stevens Miller wrote: . . . "keep your hands where I can see them and step away from the mouse" . . .
Or maybe that two's complement arithmetic and IEEE 754 numbers were well‑known before Java was developed and they took it for granted people knew how binary arithmetic works?Today, Java's philosophy, that native types must be opaque, seems somewhat in conflict with knowing why integer types are (within their ranges) always exact, but floating types cannot be similarly trusted. . . .
"Il y a peu de choses qui me soient impossibles..."
Campbell Ritchie wrote:You need to know about the structure of primitives so you know about overflow (integers) and underflow (floating‑point only). Actually floating‑point numbers can overflow too, in which case you get ±∞.
"Il y a peu de choses qui me soient impossibles..."
I hate signatures!
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote: (...)
I hate signatures!
Piet Souris wrote:OP is having a minor problem with a boundary, and so he's facing some inaccuracy
that comes with floating points. That's all. Why OP should stop coding and follow a
course in IEEE 754: it seems a bit heavy to me.
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Stevens Miller wrote:Winston's oftgiven advice to stop coding (I tend to word that as, "keep your hands where I can see them and step away from the mouse")
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions  How to Answer Questions  Format Your Code
Junilu Lacar wrote:In fact, I'm trying to free myself from having to use a mouse.
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Yeah, but is it art? What do you think tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
