L
lovecreatesbeauty
For example, line L1 and line L2 are two lines in two-dimensional
space, the start-points and end-points can be described with following
the `point_t' type. The start-points and end-points are: Line L1
(L1_str, L1_end), L2 (L2_str, L2_end).
Can I compare the float value of sloping rate of two lines to determine
whether they are parallel lines? Some paper books tell that float value
can not be compared to float value. Some people also try to convince
others on this point that do not perform the comparing on float values.
Then how can I complete the task of determining whether two lines are
parallel lines by their sloping rate?
/* type for points */
typedef struct
{
double x;
double y;
} point_t;
/* calculate the value of sloping rate of a line */
double slope(point_t pt_start, point_t pt_end);
double sl_L1 = slope (L1_str, L1_end);
double s2_L2 = slope (L2_str, L2_end);
if (s1_L1 == s2_L2) /* CAUTION: compare float data to float, is it ok?
*/
{
/* L1 and L2 are parallel lines */
}
else
{
/* L1 and L2 are not parallel lines */
}
space, the start-points and end-points can be described with following
the `point_t' type. The start-points and end-points are: Line L1
(L1_str, L1_end), L2 (L2_str, L2_end).
Can I compare the float value of sloping rate of two lines to determine
whether they are parallel lines? Some paper books tell that float value
can not be compared to float value. Some people also try to convince
others on this point that do not perform the comparing on float values.
Then how can I complete the task of determining whether two lines are
parallel lines by their sloping rate?
/* type for points */
typedef struct
{
double x;
double y;
} point_t;
/* calculate the value of sloping rate of a line */
double slope(point_t pt_start, point_t pt_end);
double sl_L1 = slope (L1_str, L1_end);
double s2_L2 = slope (L2_str, L2_end);
if (s1_L1 == s2_L2) /* CAUTION: compare float data to float, is it ok?
*/
{
/* L1 and L2 are parallel lines */
}
else
{
/* L1 and L2 are not parallel lines */
}