about summary refs log tree commit diff
path: root/converter/other/pamtosvg/point.c
blob: 690f6d80b9408a4663c9be044794a43dd225eff8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdbool.h>

#include "epsilon.h"

#include "point.h"



/* Operations on points with real coordinates.  It is not orthogonal,
   but more convenient, to have the subtraction operator return a
   vector, and the addition operator return a point.
*/



Point
point_make(float const x,
           float const y,
           float const z) {

    Point retval;

    retval.x = x;
    retval.y = y;
    retval.z = z;

    return retval;
}



bool
point_equal(Point const comparand,
            Point const comparator) {

    return
        epsilon_equal(comparand.x, comparator.x)
        &&
        epsilon_equal(comparand.y, comparator.y)
        &&
        epsilon_equal(comparand.z, comparator.z)
        ;
}



Point
point_sum(Point const coord1,
          Point const coord2) {

    Point retval;

    retval.x = coord1.x + coord2.x;
    retval.y = coord1.y + coord2.y;
    retval.z = coord1.z + coord2.z;

    return retval;
}



Point
point_scaled(Point const coord,
             float const r) {

    Point retval;

    retval.x = coord.x * r;
    retval.y = coord.y * r;
    retval.z = coord.z * r;

    return retval;
}