Example #1
0
        public bool HitsCircle(Circle3d circle, double tmin, double tmax, ref RayHit3d hit)
        {
            var dc = circle.Normal.Dot(Direction);
            var dw = circle.Normal.Dot(circle.Center - Origin);

            // If parallel to plane
            if (dc == 0.0)
            {
                return(false);
            }

            var t = dw / dc;

            if (!ComputeHit(t, tmin, tmax, ref hit))
            {
                return(false);
            }

            if (V3d.Distance(hit.Point, circle.Center) > circle.Radius)
            {
                hit.Point = V3d.NaN;
                hit.T     = tmax;
                return(false);
            }
            return(true);
        }
Example #2
0
        public Circle3d GetCircle(double height)
        {
            //circle along axis
            var      dirLength = height;
            var      radius    = GetRadius(height);
            var      dir       = Direction.Normalized * dirLength;
            Circle3d circle    = new Circle3d(Origin + dir, dir.Normalized, radius);

            return(circle);
        }
Example #3
0
 public ObliqueCone3d(V3d o, Circle3d c)
 {
     Origin = o;
     Circle = c;
 }
Example #4
0
 public Circle3d(Circle3d circle)
 {
     Center = circle.Center;
     Normal = circle.Normal;
     Radius = circle.Radius;
 }
Example #5
0
 public static bool ApproximateEquals(this Circle3d a, Circle3d b)
 => ApproximateEquals(a, b, Constant <double> .PositiveTinyValue);
Example #6
0
 public static bool ApproximateEquals(this Circle3d a, Circle3d b, double tolerance) =>
 ApproximateEquals(a.Center, b.Center, tolerance) &&
 ApproximateEquals(a.Normal, b.Normal, tolerance) &&
 ApproximateEquals(a.Radius, b.Radius, tolerance);
Example #7
0
 public bool Equals(Circle3d other)
 => Center.Equals(other.Center) && Normal.Equals(other.Normal) && Radius.Equals(other.Radius);
Example #8
0
        public static ObliqueCone3d Parse(string s)
        {
            var x = s.NestedBracketSplitLevelOne().ToArray();

            return(new ObliqueCone3d(V3d.Parse(x[0]), Circle3d.Parse(x[1])));
        }