Beispiel #1
0
static void
initEllipse(ellipse_t * ep, double cx, double cy, double a, double b,
	    double theta, double lambda1, double lambda2)
{
    ep->cx = cx;
    ep->cy = cy;
    ep->a = a;
    ep->b = b;
    ep->theta = theta;

    ep->eta1 = atan2(sin(lambda1) / b, cos(lambda1) / a);
    ep->eta2 = atan2(sin(lambda2) / b, cos(lambda2) / a);
    ep->cosTheta = cos(theta);
    ep->sinTheta = sin(theta);

    // make sure we have eta1 <= eta2 <= eta1 + 2*PI
    ep->eta2 -= TWOPI * floor((ep->eta2 - ep->eta1) / TWOPI);

    // the preceding correction fails if we have exactly eta2 - eta1 = 2*PI
    // it reduces the interval to zero length
    if ((lambda2 - lambda1 > M_PI) && (ep->eta2 - ep->eta1 < M_PI)) {
	ep->eta2 += TWOPI;
    }

    computeFoci(ep);
    computeEndPoints(ep);
    computeBounds(ep);

    /* Flatness parameters */
    ep->f = (ep->a - ep->b) / ep->a;
    ep->e2 = ep->f * (2.0 - ep->f);
    ep->g = 1.0 - ep->f;
    ep->g2 = ep->g * ep->g;
}
Beispiel #2
0
void Geom::Segment::set( Vector3 c, Vector3 d, double e )
{
	Center = c;
	Direction = d;
	Extent = e;

	computeEndPoints();
}