26 m_coords[Y] = y; |
26 m_coords[Y] = y; |
27 m_coords[Z] = z; |
27 m_coords[Z] = z; |
28 } |
28 } |
29 |
29 |
30 // ============================================================================= |
30 // ============================================================================= |
31 void vertex::move (vertex other) { |
31 void vertex::move (const vertex& other) { |
32 for (const Axis ax : g_Axes) |
32 for (const Axis ax : g_Axes) |
33 m_coords[ax] += other[ax]; |
33 m_coords[ax] += other[ax]; |
34 } |
34 } |
35 |
35 |
36 // ============================================================================= |
36 // ============================================================================= |
37 vertex vertex::midpoint (vertex& other) { |
37 vertex vertex::midpoint (const vertex& other) { |
38 vertex mid; |
38 vertex mid; |
39 |
39 |
40 for (const Axis ax : g_Axes) |
40 for (const Axis ax : g_Axes) |
41 mid[ax] = (m_coords[ax] + other[ax]) / 2; |
41 mid[ax] = (m_coords[ax] + other[ax]) / 2; |
42 |
42 |
43 return mid; |
43 return mid; |
44 } |
44 } |
45 |
45 |
46 // ============================================================================= |
46 // ============================================================================= |
47 str vertex::stringRep (const bool mangled) { |
47 str vertex::stringRep (bool mangled) const { |
48 return fmt (mangled ? "(%s, %s, %s)" : "%s %s %s", |
48 return fmt (mangled ? "(%s, %s, %s)" : "%s %s %s", |
49 ftoa (coord (X)).chars(), |
49 ftoa (coord (X)).chars(), |
50 ftoa (coord (Y)).chars(), |
50 ftoa (coord (Y)).chars(), |
51 ftoa (coord (Z)).chars()); |
51 ftoa (coord (Z)).chars()); |
52 } |
52 } |
102 vertex vertex::operator/ (const double d) const { |
102 vertex vertex::operator/ (const double d) const { |
103 vertex other (*this); |
103 vertex other (*this); |
104 return other /= d; |
104 return other /= d; |
105 } |
105 } |
106 |
106 |
107 vertex& vertex::operator+= (vertex other) { |
107 vertex& vertex::operator+= (const vertex& other) { |
108 move (other); |
108 move (other); |
109 return *this; |
109 return *this; |
|
110 } |
|
111 |
|
112 vertex& vertex::operator+ (const vertex& other) const { |
|
113 vertex newvert = *this; |
|
114 newvert.move (other); |
|
115 return newvert; |
110 } |
116 } |
111 |
117 |
112 int vertex::operator< (const vertex& other) const { |
118 int vertex::operator< (const vertex& other) const { |
113 if (operator== (other)) |
119 if (operator== (other)) |
114 return false; |
120 return false; |
169 void matrix::zero () { |
175 void matrix::zero () { |
170 memset (&m_vals[0], 0, sizeof (double) * 9); |
176 memset (&m_vals[0], 0, sizeof (double) * 9); |
171 } |
177 } |
172 |
178 |
173 // ============================================================================= |
179 // ============================================================================= |
174 matrix matrix::mult (matrix other) { |
180 matrix matrix::mult (matrix other) const { |
175 matrix val; |
181 matrix val; |
176 val.zero (); |
182 val.zero (); |
177 |
183 |
178 for (short i = 0; i < 3; ++i) |
184 for (short i = 0; i < 3; ++i) |
179 for (short j = 0; j < 3; ++j) |
185 for (short j = 0; j < 3; ++j) |