@@ -181,9 +181,21 @@ class Point3d
181181 value_type calc_length2 () const { return m_coord[0 ] * m_coord[0 ] + m_coord[1 ] * m_coord[1 ] + m_coord[2 ] * m_coord[2 ]; }
182182 value_type calc_length () const { return std::sqrt (calc_length2 ()); }
183183
184- void mirror_x () { m_coord[0 ] = -m_coord[0 ]; }
185- void mirror_y () { m_coord[1 ] = -m_coord[1 ]; }
186- void mirror_z () { m_coord[2 ] = -m_coord[2 ]; }
184+ void mirror_x ()
185+ {
186+ m_coord[1 ] = -m_coord[1 ];
187+ m_coord[2 ] = -m_coord[2 ];
188+ }
189+ void mirror_y ()
190+ {
191+ m_coord[0 ] = -m_coord[0 ];
192+ m_coord[2 ] = -m_coord[2 ];
193+ }
194+ void mirror_z ()
195+ {
196+ m_coord[0 ] = -m_coord[0 ];
197+ m_coord[1 ] = -m_coord[1 ];
198+ }
187199
188200 void mirror (Axis axis)
189201 {
@@ -546,17 +558,31 @@ class PointPad
546558
547559 void mirror_x ()
548560 {
549- for (size_t i = 0 ; i < m_x .size (); ++i)
561+ for (size_t i = 0 ; i < m_y .size (); ++i)
550562 {
551- m_x[i] = -m_x[i];
563+ m_y[i] = -m_y[i];
564+ }
565+ if (m_ndim == 3 )
566+ {
567+ for (size_t i = 0 ; i < m_z.size (); ++i)
568+ {
569+ m_z[i] = -m_z[i];
570+ }
552571 }
553572 }
554573
555574 void mirror_y ()
556575 {
557- for (size_t i = 0 ; i < m_y .size (); ++i)
576+ for (size_t i = 0 ; i < m_x .size (); ++i)
558577 {
559- m_y[i] = -m_y[i];
578+ m_x[i] = -m_x[i];
579+ }
580+ if (m_ndim == 3 )
581+ {
582+ for (size_t i = 0 ; i < m_z.size (); ++i)
583+ {
584+ m_z[i] = -m_z[i];
585+ }
560586 }
561587 }
562588
@@ -566,9 +592,13 @@ class PointPad
566592 {
567593 throw std::out_of_range (Formatter () << " PointPad::mirror_z: ndim must be 3 but is " << int (m_ndim));
568594 }
569- for (size_t i = 0 ; i < m_z.size (); ++i)
595+ for (size_t i = 0 ; i < m_x.size (); ++i)
596+ {
597+ m_x[i] = -m_x[i];
598+ }
599+ for (size_t i = 0 ; i < m_y.size (); ++i)
570600 {
571- m_z [i] = -m_z [i];
601+ m_y [i] = -m_y [i];
572602 }
573603 }
574604
@@ -714,20 +744,26 @@ class Segment3d
714744
715745 void mirror_x ()
716746 {
717- m_data.f .x0 = -m_data.f .x0 ;
718- m_data.f .x1 = -m_data.f .x1 ;
747+ m_data.f .y0 = -m_data.f .y0 ;
748+ m_data.f .y1 = -m_data.f .y1 ;
749+ m_data.f .z0 = -m_data.f .z0 ;
750+ m_data.f .z1 = -m_data.f .z1 ;
719751 }
720752
721753 void mirror_y ()
722754 {
723- m_data.f .y0 = -m_data.f .y0 ;
724- m_data.f .y1 = -m_data.f .y1 ;
755+ m_data.f .x0 = -m_data.f .x0 ;
756+ m_data.f .x1 = -m_data.f .x1 ;
757+ m_data.f .z0 = -m_data.f .z0 ;
758+ m_data.f .z1 = -m_data.f .z1 ;
725759 }
726760
727761 void mirror_z ()
728762 {
729- m_data.f .z0 = -m_data.f .z0 ;
730- m_data.f .z1 = -m_data.f .z1 ;
763+ m_data.f .x0 = -m_data.f .x0 ;
764+ m_data.f .x1 = -m_data.f .x1 ;
765+ m_data.f .y0 = -m_data.f .y0 ;
766+ m_data.f .y1 = -m_data.f .y1 ;
731767 }
732768
733769 void mirror (Axis axis)
@@ -1121,8 +1157,13 @@ class SegmentPad
11211157 size_t const nseg = size ();
11221158 for (size_t i = 0 ; i < nseg; ++i)
11231159 {
1124- x0 (i) = -x0 (i);
1125- x1 (i) = -x1 (i);
1160+ y0 (i) = -y0 (i);
1161+ y1 (i) = -y1 (i);
1162+ if (ndim () == 3 )
1163+ {
1164+ z0 (i) = -z0 (i);
1165+ z1 (i) = -z1 (i);
1166+ }
11261167 }
11271168 }
11281169
@@ -1131,8 +1172,13 @@ class SegmentPad
11311172 size_t const nseg = size ();
11321173 for (size_t i = 0 ; i < nseg; ++i)
11331174 {
1134- y0 (i) = -y0 (i);
1135- y1 (i) = -y1 (i);
1175+ x0 (i) = -x0 (i);
1176+ x1 (i) = -x1 (i);
1177+ if (ndim () == 3 )
1178+ {
1179+ z0 (i) = -z0 (i);
1180+ z1 (i) = -z1 (i);
1181+ }
11361182 }
11371183 }
11381184
@@ -1146,8 +1192,10 @@ class SegmentPad
11461192 size_t const nseg = size ();
11471193 for (size_t i = 0 ; i < nseg; ++i)
11481194 {
1149- z0 (i) = -z0 (i);
1150- z1 (i) = -z1 (i);
1195+ x0 (i) = -x0 (i);
1196+ x1 (i) = -x1 (i);
1197+ y0 (i) = -y0 (i);
1198+ y1 (i) = -y1 (i);
11511199 }
11521200 }
11531201
@@ -1272,29 +1320,41 @@ class Bezier3d
12721320 std::shared_ptr<SegmentPad<T>> sample (size_t nlocus) const ;
12731321
12741322 void mirror_x ()
1275- {
1276- x0 () = -x0 ();
1277- x1 () = -x1 ();
1278- x2 () = -x2 ();
1279- x3 () = -x3 ();
1280- }
1281-
1282- void mirror_y ()
12831323 {
12841324 y0 () = -y0 ();
12851325 y1 () = -y1 ();
12861326 y2 () = -y2 ();
12871327 y3 () = -y3 ();
1328+ z0 () = -z0 ();
1329+ z1 () = -z1 ();
1330+ z2 () = -z2 ();
1331+ z3 () = -z3 ();
12881332 }
12891333
1290- void mirror_z ()
1334+ void mirror_y ()
12911335 {
1336+ x0 () = -x0 ();
1337+ x1 () = -x1 ();
1338+ x2 () = -x2 ();
1339+ x3 () = -x3 ();
12921340 z0 () = -z0 ();
12931341 z1 () = -z1 ();
12941342 z2 () = -z2 ();
12951343 z3 () = -z3 ();
12961344 }
12971345
1346+ void mirror_z ()
1347+ {
1348+ x0 () = -x0 ();
1349+ x1 () = -x1 ();
1350+ x2 () = -x2 ();
1351+ x3 () = -x3 ();
1352+ y0 () = -y0 ();
1353+ y1 () = -y1 ();
1354+ y2 () = -y2 ();
1355+ y3 () = -y3 ();
1356+ }
1357+
12981358 void mirror (Axis axis)
12991359 {
13001360 switch (axis)
0 commit comments