Exemple #1
0
        public static float Combine(float left, float right, float radius, int n)
        {
            left = -left;
            float m = min(left, right);

            //avoid the expensive computation where not needed (produces discontinuity though)
            if ((left < radius) && (right < radius))
            {
                float2 p            = float2(left, right);
                float  columnradius = radius * sqrt(2) / n / 2.0f;
                columnradius = radius * sqrt(2) / ((n - 1) * 2 + sqrt(2));

                Rotate45.Modify(ref p);
                p.y += columnradius;
                p.x -= sqrt(2) / 2 * radius;
                p.x += -columnradius *sqrt(2) / 2;

                if (mod(n, 2) == 1)
                {
                    p.y += columnradius;
                }
                ModSimple.Mod1(ref p.y, columnradius * 2);

                float result = -length(p) + columnradius;
                result = max(result, p.x);
                result = min(result, left);
                return(-min(result, right));
            }
            else
            {
                return(-m);
            }
        }
Exemple #2
0
 public static float Combine(float left, float right, float radius, int n)
 {
     if ((left < radius) && (right < radius))
     {
         float2 p            = float2(left, right);
         float  columnradius = radius * sqrt(2) / ((n - 1) * 2 + sqrt(2));
         Rotate45.Modify(ref p);
         p.x -= sqrt(2) / 2 * radius;
         p.x += columnradius * sqrt(2);
         if (mod(n, 2) == 1)
         {
             p.y += columnradius;
         }
         // At this point, we have turned 45 degrees and moved at a point on the
         // diagonal that we want to place the columns on.
         // Now, repeat the domain along this direction and place a circle.
         ModSimple.Mod1(ref p.y, columnradius * 2);
         float result = length(p) - columnradius;
         result = min(result, p.x);
         result = min(result, left);
         return(min(result, right));
     }
     else
     {
         return(min(left, right));
     }
 }
Exemple #3
0
 public void Modify(ref float3 pos)
 {
     Rotate45.Modify(ref pos, Axis);
 }