Example #1
0
 public static Vector3 clamp(Vector3 value, Vector3 min, Vector3 max)
 {
     return(new Vector3(
                MyMath.max(min.x, MyMath.min(value.x, max.x)),
                MyMath.max(min.y, MyMath.min(value.y, max.y)),
                MyMath.max(min.z, MyMath.min(value.z, max.z))));
 }
Example #2
0
 public static Vector4 clamp(Vector4 value, float min, float max)
 {
     return(new Vector4(
                MyMath.max(min, MyMath.min(value.x, max)),
                MyMath.max(min, MyMath.min(value.y, max)),
                MyMath.max(min, MyMath.min(value.z, max)),
                MyMath.max(min, MyMath.min(value.w, max))));
 }
Example #3
0
 public static Vector4 clamp(Vector4 value, Vector4 min, Vector4 max)
 {
     return(new Vector4(
                MyMath.max(min.x, MyMath.min(value.x, max.x)),
                MyMath.max(min.y, MyMath.min(value.y, max.y)),
                MyMath.max(min.z, MyMath.min(value.z, max.z)),
                MyMath.max(min.w, MyMath.min(value.w, max.w))));
 }
Example #4
0
        //TODO solve IK and tick normal in different methods
        public override void tick(float dt)
        {
            Vector3 targetLocal = targetAbs.v - basisAbs.v;
            float   pole        = -targetLocal.normalized.scalarProduct(axisAbs);
            float   mul         = MyMath.mix(rotSpeedAtEquator, rotSpeedAtPole, pole) * dt;
            Vector3 n           = axisAbs;

            if (Application.isPlaying) //for battle mech 2 TODO place elbow at custom position
            {
                if (poleAxisStrength > 0)
                {
                    n = n + secondaryAxisAbs.mul(pole * poleAxisStrength);
                }
            }
            resultAbs.v = lastResult.mix(targetLocal.crossProduct(n).normalized(), MyMath.min(mul, 1)).normalized;
            lastResult  = resultAbs.v;
        }
Example #5
0
 public static Vector2 clamp(Vector2 value, Vector2 min, Vector2 max)
 {
     return(new Vector2(MyMath.max(min.x, MyMath.min(value.x, max.x)), MyMath.max(min.y, MyMath.min(value.y, max.y))));
 }
Example #6
0
 public static float clamp(float value, float min, float max)
 {
     return(MyMath.max(min, MyMath.min(value, max)));
 }