automatic commit
[folded-ctf.git] / pose.cc
diff --git a/pose.cc b/pose.cc
index ed6c705..f0aa9d3 100644 (file)
--- a/pose.cc
+++ b/pose.cc
@@ -26,7 +26,7 @@ Pose::Pose() {
 
 void Pose::horizontal_flip(scalar_t scene_width) {
   _head_xc = scene_width - 1 - _head_xc;
-  _body_xc = scene_width - 1 - _body_xc;
+  _belly_xc = scene_width - 1 - _belly_xc;
 }
 
 void Pose::translate(scalar_t dx, scalar_t dy) {
@@ -36,8 +36,8 @@ void Pose::translate(scalar_t dx, scalar_t dy) {
   _bounding_box_ymax += dy;
   _head_xc += dx;
   _head_yc += dy;
-  _body_xc += dx;
-  _body_yc += dy;
+  _belly_xc += dx;
+  _belly_yc += dy;
 }
 
 void Pose::scale(scalar_t factor) {
@@ -48,8 +48,8 @@ void Pose::scale(scalar_t factor) {
   _head_xc *= factor;
   _head_yc *= factor;
   _head_radius *= factor;
-  _body_xc *= factor;
-  _body_yc *= factor;
+  _belly_xc *= factor;
+  _belly_yc *= factor;
 }
 
 const scalar_t tolerance_scale_ratio_for_hit = 1.5;
@@ -74,7 +74,7 @@ bool Pose::hit(int level, Pose *pose) {
 
   // Belly location
 
-  if(sq(_body_xc - pose->_body_xc) + sq(_body_yc - pose->_body_yc) > 4 * sq_delta)
+  if(sq(_belly_xc - pose->_belly_xc) + sq(_belly_yc - pose->_belly_yc) > 4 * sq_delta)
     return false;
 
   if(level == 1) return true;
@@ -106,7 +106,7 @@ bool Pose::collide(int level, Pose *pose) {
 
   // Belly location
 
-  if(sq(_body_xc - pose->_body_xc) + sq(_body_yc - pose->_body_yc) <= sq_delta)
+  if(sq(_belly_xc - pose->_belly_xc) + sq(_belly_yc - pose->_belly_yc) <= sq_delta)
     return true;
 
   if(level == 1) return false;
@@ -122,38 +122,26 @@ void Pose::draw(int thickness, int r, int g, int b, int level, RGBImage *image)
   image->draw_ellipse(thickness, r, g, b,
                       _head_xc, _head_yc, _head_radius, _head_radius, 0);
 
-  //   int vx = int(cos(_head_tilt) * _head_radius);
-  //   int vy = int(sin(_head_tilt) * _head_radius);
-  //   image->draw_line(thickness, r, g, b, _head_xc, _head_yc, _head_xc + vx, _head_yc + vy);
-
   if(level == 1) {
 
-    //     image->draw_line(thickness, r, g, b,
-    //                      int(_body_xc) - delta, int(_body_yc),
-    //                      int(_body_xc) + delta, int(_body_yc));
-
-    //     image->draw_line(thickness, r, g, b,
-    //                      int(_body_xc), int(_body_yc) - delta,
-    //                      int(_body_xc), int(_body_yc) + delta);
-
-    scalar_t vx = _body_xc - _head_xc, vy = _body_yc - _head_yc;
+    scalar_t vx = _belly_xc - _head_xc, vy = _belly_yc - _head_yc;
     scalar_t l = sqrt(vx * vx + vy * vy);
     vx /= l;
     vy /= l;
 
-    scalar_t body_radius = 12 + thickness / 2;
+    scalar_t belly_radius = 12 + thickness / 2;
 
-    if(l > _head_radius + thickness + body_radius) {
+    if(l > _head_radius + thickness + belly_radius) {
       image->draw_line(thickness, r, g, b,
                        _head_xc + vx * (_head_radius + thickness/2),
                        _head_yc + vy * (_head_radius + thickness/2),
-                       _body_xc - vx * (body_radius - thickness/2),
-                       _body_yc - vy * (body_radius - thickness/2));
+                       _belly_xc - vx * (belly_radius - thickness/2),
+                       _belly_yc - vy * (belly_radius - thickness/2));
     }
 
     // An ugly way to make a filled disc
-    for(scalar_t u = 0; u < body_radius; u += thickness / 2) {
-      image->draw_ellipse(thickness, r, g, b, _body_xc, _body_yc, u, u, 0);
+    for(scalar_t u = 0; u < belly_radius; u += thickness / 2) {
+      image->draw_ellipse(thickness, r, g, b, _belly_xc, _belly_yc, u, u, 0);
     }
 
   }
@@ -163,8 +151,8 @@ void Pose::print(ostream *out) {
   (*out) << "  _head_xc " << _head_xc << endl;
   (*out) << "  _head_yc " << _head_yc << endl;
   (*out) << "  _head_radius " << _head_radius << endl;
-  (*out) << "  _body_xc " << _body_xc << endl;
-  (*out) << "  _body_yc " << _body_yc << endl;
+  (*out) << "  _belly_xc " << _belly_xc << endl;
+  (*out) << "  _belly_yc " << _belly_yc << endl;
 }
 
 void Pose::write(ostream *out) {
@@ -174,8 +162,8 @@ void Pose::write(ostream *out) {
   write_var(out, &_bounding_box_ymax);
   write_var(out, &_head_xc); write_var(out, &_head_yc);
   write_var(out, &_head_radius);
-  write_var(out, &_body_xc);
-  write_var(out, &_body_yc);
+  write_var(out, &_belly_xc);
+  write_var(out, &_belly_yc);
 }
 
 void Pose::read(istream *in) {
@@ -185,6 +173,6 @@ void Pose::read(istream *in) {
   read_var(in, &_bounding_box_ymax);
   read_var(in, &_head_xc); read_var(in, &_head_yc);
   read_var(in, &_head_radius);
-  read_var(in, &_body_xc);
-  read_var(in, &_body_yc);
+  read_var(in, &_belly_xc);
+  read_var(in, &_belly_yc);
 }