How to know two lines are a pare parallel lines



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 */
}

--
Sincerely,
lovecreatesbeauty

.



Relevant Pages

  • Re: pointer and array
    ... impossible to compare the values, ... int 3 and the float 3.14, that are equal when we convert them both ... the "double" 33554433.0 becomes 33554432.0 after conversion to ...
    (comp.lang.c)
  • Re: How to know two lines are a pare parallel lines
    ... Can I compare the float value of sloping rate of two lines to determine ... Notice that if your points are expressible in integral or even rational terms, then you may be able to avoid floating point representations entirely. ...
    (comp.lang.c)
  • Re: Comparing floating point values in Java
    ... when comparing floating point ... will unchanged values compare strictly true if equal? ... float a = 1; ... public static boolean areEqual(float a, float b, float delta) { ...
    (comp.lang.java.programmer)
  • Re: compare two float values
    ... float t, check; ... Don't compare for equality, won't work for float, rather compare ... compatible implementation, exactly one of these three will be true ... operations are usually not exact, and two calculations that you think ...
    (comp.lang.c)
  • java performance on machines
    ... Primarily the goal is to compare cpu/memory power on different operations, ... The idea is to write a series of tests in java, both integer and float based, which I then run on the machines to compare their performance. ... I was thinking of writing tests based on float operations and on integer operations. ...
    (comp.lang.java.help)