Exemplo n.º 1
0
bool 

FlatEllipse::intersect(const FlatLine &line, FlatPoint &i1, FlatPoint &i2) const
{
  const fixed er = ab();
  const fixed ier = ba();
  FlatLine s_line = line;

  s_line.sub(p);
  s_line.rotate(theta.Reciprocal());
  s_line.mul_y(er);

  if (s_line.intersect_czero(a, i1, i2)) {
    i1.mul_y(ier);
    i1.rotate(theta);
    i1.add(p);
    
    i2.mul_y(ier);
    i2.rotate(theta);
    i2.add(p);
    
    return true;
  }

  return false;
}
Exemplo n.º 2
0
FlatEllipse::FlatEllipse(const FlatPoint &_f1, const FlatPoint &_f2,
                         const FlatPoint &_ap)
  :f1(_f1),f2(_f2),ap(_ap)
{
  const FlatLine f12(f1, f2);
  p = f12.ave();
  theta = f12.angle();
  const fixed csq = f12.dsq();
  a = (f1.d(ap) + f2.d(ap));
  b = half(sqrt(a * a - csq));
  a = half(a);

  // a.sin(t) = ap.x
  // b.cos(t) = ap.y

  FlatPoint op = ap;
  op.sub(p);
  op.rotate(-theta);
  theta_initial = Angle::radians(atan2(op.y * a, op.x * b)).as_delta();
}