示例#1
0
 public void Clear()
 {
     m_small     = 0;
     m_large     = 0;
     m_dataRange = Range1d.Invalid;
     m_histo.Set(0);
 }
示例#2
0
 public Histogram(Range1d range, int slotCount)
 {
     m_slotRange = range;
     m_scale     = slotCount / (range.Max - range.Min);
     m_small     = 0;
     m_large     = 0;
     m_dataRange = Range1d.Invalid;
     m_histo     = new long[slotCount];
 }
示例#3
0
            /// <summary>
            /// Computes the bounding box of the Kochanek-Bartels spline
            /// defined by points the specified points, tension, and bias.
            /// </summary>
            public static Box3d Bounds(Range1d domain,
                                       V3d p0, V3d p1, V3d p2, V3d p3, double tension, double bias)
            {
                var oneMinusTensionHalf = (1 - tension) * 0.5;
                var x1 = oneMinusTensionHalf * (1 + bias);
                var x2 = oneMinusTensionHalf * (1 - bias);
                var s0 = p1 - p0; var s1 = p2 - p1; var s2 = p3 - p2;
                var m0 = x1 * s0 + x2 * s1;
                var m1 = x1 * s1 + x2 * s2;

                var bb = Box3d.Invalid;

                bb.ExtendBy(domain.Min > 0
                    ? Ipol.KochanekBartels.Eval(domain.Min, p0, p1, p2, p3, tension, bias)
                    : p1);
                bb.ExtendBy(domain.Max < 1
                    ? Ipol.KochanekBartels.Eval(domain.Max, p0, p1, p2, p3, tension, bias)
                    : p2);

                var a = 6 * p1 + 3 * m0 + 3 * m1 - 6 * p2;
                var b = -6 * p1 - 4 * m0 - 2 * m1 + 6 * p2;
                var c = m0;

                for (int i = 0; i < 3; i++)
                {
                    var t = Polynomial.RealRootsOf(a[i], b[i], c[i]);
                    var p0x = p0[i]; var p1x = p1[i]; var p2x = p2[i]; var p3x = p3[i];
                    if (t.E0 > domain.Min && t.E0 < domain.Max)
                    {
                        bb.ExtendDimBy(i,
                                       KochanekBartels.Eval(t.E0, p0x, p1x, p2x, p3x, tension, bias)
                                       );
                    }
                    if (t.E1 > domain.Min && t.E1 < domain.Max)
                    {
                        bb.ExtendDimBy(i,
                                       KochanekBartels.Eval(t.E1, p0x, p1x, p2x, p3x, tension, bias)
                                       );
                    }
                }

                return(bb);
            }
 //put here by haaser (Method needed in Intersections.cs: Line2d.Intersects(Line2d)
 //feel free to relocate it if this is a bad place for this Extension
 /// <summary>
 /// Checks if 2 ranges intersect each other with tolerance parameter.
 /// </summary>
 public static bool Intersects(this Range1d r0, Range1d range, double eps, out Range1d result)
 {
     result = Range1d.Invalid;
     if (r0.Min - eps > range.Max)
     {
         return(false);
     }
     else if (r0.Max + eps < range.Min)
     {
         return(false);
     }
     else
     {
         result = new Range1d(System.Math.Max(r0.Min, range.Min), System.Math.Min(r0.Max, range.Max));
         if (result.Size < eps)
         {
             double center = result.Center;
             result.Min = center - eps;
             result.Max = center + eps;
         }
         return(true);
     }
 }
示例#5
0
 /// <summary>
 /// Gets segment on the ray starting at range.Min * direction from origin
 /// and ending at range.Max * direction from origin.
 /// </summary>
 public Line2d GetLine2dOnRay(Range1d range)
 => new Line2d(Origin + Direction * range.Min, Origin + Direction * range.Max);
示例#6
0
 /// <summary>
 /// Gets segment on the ray starting at range.Min * direction from origin
 /// and ending at range.Max * direction from origin.
 /// </summary>
 public Line2d GetLine2dOnRay(Range1d range)
 {
     return(new Line2d(Origin + Direction * range.Min, Origin + Direction * range.Max));
 }
示例#7
0
 public Range1f(Range1d box)
 {
     Min = (float)box.Min;
     Max = (float)box.Max;
 }