public void EvalTest() { Polynom <double> P = new Polynom <double>(Vector <double> .Create(new double[] { 1, 1, 1 })); Assert.AreEqual(2, P.Degree); Assert.AreEqual(1, P.Eval(0)); Assert.AreEqual(3, P.Eval(1)); Assert.AreEqual(1, P.Eval(-1)); Assert.AreEqual(7, P.Eval(2)); Assert.AreEqual(13, P.Eval(3)); }
public override Polynom GetImplicitPolynomial() { if (implicitPolynomial == null) { PolynomVector w = zAxis ^ (location.ToVector() - PolynomVector.xyz); // the distance of a point to the axis Polynom l = zAxis * PolynomVector.xyz - zAxis * location.ToVector(); // the distance from location along the axis //(w*w)/(l*l)==(xAxis*xAxis)/(zAxis*zAxis) == tan(half opening angle) implicitPolynomial = (w * w) - ((xAxis * xAxis) / (zAxis * zAxis)) * (l * l); double d1 = implicitPolynomial.Eval(PointAt(new GeoPoint2D(0.5, 0.5))); double d2 = implicitPolynomial.Eval(PointAt(new GeoPoint2D(10, -10))); GeoPoint p = PointAt(new GeoPoint2D(1, 0)) + GetNormal(new GeoPoint2D(1, 0)).Normalized; // a point with distance 1 from the cone double d = implicitPolynomial.Eval(p); // this should be 1 implicitPolynomial = (1 / d) * implicitPolynomial; // OK, this makes a good scaling (but it is not the distance) } return(implicitPolynomial); }
public override Polynom GetImplicitPolynomial() { if (implicitPolynomial == null) { PolynomVector x = (new GeoVector(center.x, center.y, center.z) - PolynomVector.xyz); implicitPolynomial = (x * x) - xAxis * xAxis; // we need to scale the implicit polynomial so that it yields the true distance to the surface GeoPoint p = center + xAxis + xAxis.Normalized; // a point outside the sphere with distance 1 double d = implicitPolynomial.Eval(p); // this should be 1 when the polynomial is normalized if ((xAxis ^ yAxis) * zAxis < 0) { d = -d; // inverse oriented sphere } implicitPolynomial = (1 / d) * implicitPolynomial; // normalize the polynomial } return(implicitPolynomial); }
public override Polynom GetImplicitPolynomial() { if (implicitPolynomial == null) { GeoVector zNormed = zAxis.Normalized; PolynomVector x = zNormed ^ (new GeoVector(location.x, location.y, location.z) - PolynomVector.xyz); implicitPolynomial = (x * x) - xAxis * xAxis; // we need to scale the implicit polynomial so that it yields the true distance to the surface GeoPoint p = location + xAxis + xAxis.Normalized; // a point outside the cylinder with distance 1 double d = implicitPolynomial.Eval(p); // this should be 1 when the polynomial is normalized if ((xAxis ^ yAxis) * zAxis < 0) { d = -d; // inverse oriented cylinder } implicitPolynomial = (1 / d) * implicitPolynomial; // normalize the polynomial } return(implicitPolynomial); }