Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Java.awt.geom suitable for discrete calculations?

The package java.awt.geom allows testing if a point lies within a rectangle and similar questions. In particular I need to know if a rectangle is intersected by a line. All involved values are integers.

However, it appears we cannot have those calculations use integers instead of floating point. As I need a completely consistent and reproducible result (its factual accuracy is not as important, actually), I am worried this might be a bad approach. The program will be deployed on Windows, Linux and Android platform, and I do not have full control over the machines.

I have implemented the required algorithm myself (using pure integer arithmetic), and it suffices all my needs. Yet, if possible, I would like to use the preprovided package. Is there some sort of guarantee on its consistency?

like image 616
mafu Avatar asked Mar 24 '26 17:03

mafu


1 Answers

Yet, if possible, I would like to use the preprovided package.

It is unlikely the J2SE classes will be available in Android, so stick with your own custom rolled solution.

like image 69
Andrew Thompson Avatar answered Mar 26 '26 07:03

Andrew Thompson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!