Example #1
0
    float FCT_BBSK(Vector3 pos)
    {
        Vector3 cFcParams = new Vector3(2.18f, -0.18f, 0);
        Vector3 CSize     = new Vector3(1.4f, 0.87f, 1.1f);
        Vector3 p;

        p.x = 2 * pos.x;
        p.y = 2 * pos.z;
        p.z = 2 * pos.y;
        float scale = 1.0f;

        for (int i = 0; i < 4; i++)
        {
            p.x = 2 * Mathf.Clamp(p.x, -CSize.x, CSize.x) - p.x;
            p.y = 2 * Mathf.Clamp(p.y, -CSize.y, CSize.y) - p.y;
            p.z = 2 * Mathf.Clamp(p.z, -CSize.z, CSize.x) - p.z;
            float r2 = Vector3.Dot(p, p);
            //float r2 = dot(p,p+sin(p.z*.5)); //Alternate fractal
            float k = Mathf.Max((2f) / (r2), .17f);
            p *= k;
            //p *=rot;
            //p= p.yzx;
            p     += new Vector3(0.2f, 0.2f, -0.5f);
            scale *= k;
        }

        p.x = 2 * Mathf.Clamp(p.x, -CSize.x * 4, CSize.x * 4) - p.x;
        p.y = 2 * Mathf.Clamp(p.y, -CSize.y * 4, CSize.y * 4) - p.y;
        p.z = 2 * Mathf.Clamp(p.z, -CSize.z * 4, CSize.x * 4) - p.z;

        for (int i = 0; i < 8; i++)
        {
            p.x = 2 * Mathf.Clamp(p.x, -CSize.x, CSize.x) - p.x;
            p.y = 2 * Mathf.Clamp(p.y, -CSize.y, CSize.y) - p.y;
            p.z = 2 * Mathf.Clamp(p.z, -CSize.z, CSize.x) - p.z;
            float r2 = Vector3.Dot(p, p);
            //float r2 = dot(p,p+sin(p.z*.3)); //Alternate fractal
            float k = Math.Max((cFcParams.x) / (r2), 0.027f);
            p     *= k;
            scale *= k;
            p.y   += cFcParams.y;
        }

        float l = Mathf.Sqrt(Vector2.SqrMagnitude(new Vector2(p.x, p.y)));
        //l = mix(l,l2,0.5);
        float rxy = l - 4;
        float n   = p.z;

        rxy = Math.Max(rxy, -(n) / 4);
        float dist = (rxy) / Math.Abs(scale);

        dist *= .75f;

        return(dist);
    }
Example #2
0
 static public int SqrMagnitude(IntPtr l)
 {
     try{
         UnityEngine.Vector2 self = (UnityEngine.Vector2)checkSelf(l);
         System.Single       ret  = self.SqrMagnitude();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #3
0
 static int SqrMagnitude(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Vector2 obj = (UnityEngine.Vector2)ToLua.CheckObject(L, 1, typeof(UnityEngine.Vector2));
         float o = obj.SqrMagnitude();
         LuaDLL.lua_pushnumber(L, o);
         ToLua.SetBack(L, 1, obj);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #4
0
 public static Vector2 ProjectOnto(this Vector2 source, Vector2 target)
 {
     return (Vector2.Dot(source, target) / target.SqrMagnitude()) * target;
 }
Example #5
0
 public static bool operator !=(Vector2 lhs, Vector2 rhs)
 {
     return((double)Vector2.SqrMagnitude(lhs - rhs) >= 9.99999943962493E-11);
 }
Example #6
0
 public static bool operator!=(Vector2 lhs, Vector2 rhs)
 {
     return(Vector2.SqrMagnitude(lhs - rhs) >= kEpsilon);
 }
Example #7
0
 public static bool operator !=(Vector2 lhs, Vector2 rhs)
 {
     return(Vector2.SqrMagnitude(lhs - rhs) >= 9.99999944E-11f);
 }
Example #8
0
    static bool Vector2_SqrMagnitude(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 0)
        {
            UnityEngine.Vector2 argThis = (UnityEngine.Vector2)vc.csObj;                JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(argThis.SqrMagnitude()));
            JSMgr.changeJSObj(vc.jsObjID, argThis);
        }

        return(true);
    }