예제 #1
0
        bool
        Splitter::collide_with_ball (Splitter& self,
                                     Ball&     other)
        {
            if( self.m_collided == false ) // Splitter としての効果を持っている
            {
                if( fge(self.get_distance(other), 0.0) )
                {
                    Vector<double> norm, va, vb;

                    // ボールは壁面弾性衝突で跳ね返す
                    decompose_velocity(self, other, norm, va, vb);
                    vb.set_x(-vb.get_x());
                    other.set_velocity(norm.nob_compose(vb));

                    // 部品を配置する
                    std::list<Segment>::iterator it;
                    for( it = self.m_segm_list.begin(); it != self.m_segm_list.end(); ++it )
                    {
                        it->droplet->set_position(self.get_position() + it->rel_pos); // 相対座標で位置合わせ
                        self.get_manager().attach(*(it->droplet)); // droplet のコピーを追加する
                    }

                    self.set_alive(false); // self を破棄する

                    return true;
                }

                return false;
            }
            else
            {
                return Ball::collide_with_globule(other, self);
            }
        }
예제 #2
0
파일: cmpsf-1.c 프로젝트: JamesLinus/gcc
void
test (void)
{
  int i, j, *res = correct_results;

  for (i = 0; i < 8; i++)
    {
      float arg0 = args[i];
      for (j = 0; j < 8; j++)
	{
	  float arg1 = args[j];

	  if (feq (arg0, arg1) != *res++)
	    abort ();
	  if (fne (arg0, arg1) != *res++)
	    abort ();
	  if (flt (arg0, arg1) != *res++)
	    abort ();
	  if (fge (arg0, arg1) != *res++)
	    abort ();
	  if (fgt (arg0, arg1) != *res++)
	    abort ();
	  if (fle (arg0, arg1) != *res++)
	    abort ();
	}
    }
}