/// <summary> /// Constructs a plane from an equation /// ax+by+cz+d=0. /// </summary> public Plane(double a, double b, double c, double d) : this() { var eqn = new PlaneEquation(a, b, c, d); if (CreateFromEquation(eqn)) { this.m_zaxis.Normalize(); } else { throw new ArgumentException(); } }
/// <summary> /// Evaluates whether or not this circle is co-planar with a given plane. /// </summary> /// <param name="plane">Plane.</param> /// <param name="tolerance">Tolerance to use.</param> /// <returns>true if the circle plane is co-planar with the given plane within tolerance.</returns> public bool IsInPlane(Plane plane, double tolerance) { double d; int i; var equ = new PlaneEquation(plane.GetPlaneEquation()); for (i = 0; i < 8; i++) { d = equ.ValueAt(PointAt(0.25 * i * Math.PI)); if (Math.Abs(d) > tolerance) { return(false); } } return(true); }
public bool CreateFromEquation(PlaneEquation eqn) { bool b = false; equation = eqn; m_zaxis.X = eqn.X; m_zaxis.Y = eqn.Y; m_zaxis.Z = eqn.Z; double d = m_zaxis.Length; if (d > 0.0) { d = 1.0 / d; m_zaxis *= d; m_origin = (Point3D)(-d * eqn.D * m_zaxis); b = true; } m_xaxis.PerpendicularTo(m_zaxis); m_xaxis.Normalize(); m_yaxis = m_zaxis.Cross(m_xaxis); m_yaxis.Normalize(); return(b); }