Home  >  Q&A  >  body text

java - Precision issues in three-point collinearity and other point-based algorithms

In the algorithm for calculating the collinearity of three points, we tried to calculate that the slope of any two straight lines is the same and use Heron's formula to calculate the area to be 0.
The problems encountered are as follows:

The length cannot be expressed accurately. For example, the distance between (1,1) and (2,2) is square root 2 (such a number cannot be expressed in the program). When calculating the area, we get The result is not 0;

为情所困为情所困2702 days ago548

reply all(1)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-27 17:42:03

    Using their squares, which is 2, can be expressed accurately.

    reply
    0
  • Cancelreply