Yep, that is the problem my post is about. It's quite obvious from
the rectangle example.
On 18.4.2013 16:48, Alexander Nyßen
wrote:
I was talking of what is performed when updating the int-fields
within the precision classes, i.e. the code within
PrecisionGeometry#doubleToInteger():
/**
* Converts a double value into an integer value, avoiding
rounding effects.
*
* @param doubleValue
* the double value to convert
* @return the integer value for the double.
*/
protected static final int doubleToInteger(double
doubleValue) {
return (int) Math.floor(doubleValue + 0.000000001);
}
My point was that changing that from Math.floor() to
Math.round() would probably be reasonable...
Cheers
Alexander
Floor
is used only because otherwise casting
0.9 and -0.9 to an int would give you the same number.
For positive
values, it isn't doing anything.
Are you filling or
drawing the rectangle?
-Randy
Hi Jan,
you are right, what you are facing here
is one of the
several inconsistencies within the current Draw2d
geometry API, and one
of the reasons we started to build a new one in GEF4.
You would actually
have to switch to integer-based precision when
performing the calculation
of the drawing position (i.e. y = line.y() -
rect.height()) for the rectangle.
I agree that in general rounding would probably lead
to better results,
so that's what we will do when rendering GEF4
geometries (which are completely
based on double-precision) within a GEF4 Graphics.
Cheers
Alexander
Am 17.04.2013 um 12:16 schrieb Jan
Krakora <jan.krakora.cz@xxxxxxxxx>:
Hi all,
since the GEF forum is basically dead I would like to
ask you here. Why
is used Math.floor in all Precision* classes?
Let me give you an example:
First of all, I use PrecisionPoint,
PrecisionRectangle, PrecisionDimension
everywhere.
So there is a line with y coordinate 31.14. You have a
rectangle with height
18.315 that you would like to draw exactly above the
line
so its bottom edge overlaps the line. But since the
converting from double
to int is done using Math.floor the coordinates
are as such:
the line:
y: 31.14 -> 31
the rectangle
y: 31.14 - 18.315 = 12.825 -> 12
height: 18.315 -> 18
As you can see the rectangle will be rendered above
the line. They don't
overlap. Why aren't double coordinates rounded?
Do I compute the y of the rectangle in wrong way?
Thanks, Jan Krakora.
_______________________________________________
gef-dev mailing list
gef-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/gef-dev
--
Dr. Alexander Nyßen
Dipl.-Inform.
Software-Engineer
Telefon: +49 (0) 231 / 98 60-210
Telefax: +49 (0) 231 / 98 60-211
Mobil: +49 (0) 151 / 17396743
http://www.itemis.de
alexander.nyssen@xxxxxxxxx
itemis AG
Am Brambusch 15-24
44536 Lünen
Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr.
Georg Pietrek, Jens
Trompeter, Sebastian Neus
Aufsichtsrat: Dr. Burkhard Igel (Vors.), Stephan
Grollmann, Michael Neuhaus
_______________________________________________
gef-dev mailing list
gef-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/gef-dev
_______________________________________________
gef-dev mailing list
gef-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/gef-dev
--
Dr. Alexander Nyßen
Dipl.-Inform.
Software-Engineer
Telefon: +49 (0) 231 / 98 60-210
Telefax: +49 (0) 231 / 98 60-211
Mobil: +49 (0) 151 / 17396743
http://www.itemis.de
alexander.nyssen@xxxxxxxxx
itemis AG
Am Brambusch 15-24
44536 Lünen
Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr.
Georg Pietrek, Jens Trompeter, Sebastian Neus
Aufsichtsrat: Dr. Burkhard Igel (Vors.),
Stephan Grollmann, Michael Neuhaus
_______________________________________________
gef-dev mailing list
gef-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/gef-dev
|