Sin() public static method

public static Sin ( float f ) : float
f float
return float
コード例 #1
0
        /// <summary>
        /// 更新相机位置
        /// </summary>
        private void UpdatePosition()
        {
            Vector3 targetPos = this.tank.Point;

            Vector3 cameraPos;

            float d = this.distance * Mathf.Cos(roll);

            float height = this.distance * Mathf.Sin(roll);

            cameraPos.x = targetPos.x + d * Mathf.Sin(rot);

            cameraPos.y = targetPos.y + height;

            cameraPos.z = targetPos.z + d * Mathf.Cos(rot);

            this.MainCamera.transform.position = cameraPos;

            this.MainCamera.transform.LookAt(this.tank.Point);


            return;

            //Vector3 cameraPos = this.mainCamera.transform.position;
            this.mainCamera.transform.position = new Vector3(this.tank.Position.x, this.tank.Position.y + 5, this.tank.Position.z - 6);
            this.mainCamera.transform.LookAt(this.tank.Position);

            //this.mainCamera.transform.eulerAngles = new Vector3(30,0,0);
        }
コード例 #2
0
    private void GenerateBaseValues()
    {
        if (fromDegrees)
        {
            radians = (degrees * M.PI) / 180;
        }
        else
        {
            degrees = (radians * 180) / M.PI;
        }

        //If allowed, use time as input.
        t = (float)EditorApplication.timeSinceStartup;
        if (useTime)
        {
            radians = t;
            degrees = degrees = (radians * 180) / M.PI;
        }

        //Clamp the values to a readable range
        radians = M.Repeat(radians, 2 * M.PI);
        degrees = M.Repeat(degrees, 360);

        //local variables for simplicity
        sine    = M.Sin(radians);
        cosine  = M.Cos(radians);
        tangent = M.Tan(radians);
    }
コード例 #3
0
/**
 * Tweet cart is the whole script, fit in one tweet, i.e. code length must be <= 280 characters
 *
 * Tigra tweet cart shortcuts:
 *
 * Functions:
 * TIC() is called 60 times per second.
 *
 * Variables:
 * t:  elapsed time in seconds
 * f:  frame counter
 *
 * Aliases:
 * B:  bool
 * F:  float
 * I:  int
 * M:  UnityEngine.Mathf
 * R:  UnityEngine.Random
 * S:  System.String
 * V2: UnityEngine.Vector2
 * V3: UnityEngine.Vector3
 * Z:  Tic80
 *
 * Delegates:
 * CD: circ & circb delegate
 * RD: rect & rectb delegate
 * TD: tri & trib delegate
 *
 * Beautify/minify C# online tool:
 * https://codebeautify.org/csharpviewer
 */
class Tc5 : Z { F x = 96, y = 24, d = .01f; void TIC()
                {
                    cls(16); if (btn(0))
                    {
                        y -= d;
                    }
                    if (btn(1))
                    {
                        y += d;
                    }
                    if (btn(2))
                    {
                        x -= d;
                    }
                    if (btn(3))
                    {
                        x += d;
                    }
                    for (I e = 0; e < 136; e += 2)
                    {
                        for (I b = 0; b < 240; b += 50)
                        {
                            rect(b, e, M.Sin((y * (e * b) / x) + (F)f / 200) * 50, 1, R.Range(6, 10));
                        }
                    }
                }
コード例 #4
0
        /// <summary>
        /// Rotates the given Vector2 counterclockwise by the given angle
        /// </summary>
        public static U.Vector2 RotateVector2(U.Vector2 vec, float angle)
        {
            angle = U.Mathf.Deg2Rad * angle;
            var _sinAngle = Mathf.Sin(angle);
            var _cosAngle = Mathf.Cos(angle);

            return(new U.Vector2(_cosAngle * vec.x - _sinAngle * vec.y, _sinAngle * vec.x + _cosAngle * vec.y));
        }
コード例 #5
0
 public static float InOut(float k)
 {
     if ((k *= 2f) < 1f)
     {
         return(-0.5f * Mathf.Pow(2f, 10f * (k -= 1f)) * Mathf.Sin((k - 0.1f) * (2f * Mathf.PI) / 0.4f));
     }
     return(Mathf.Pow(2f, -10f * (k -= 1f)) * Mathf.Sin((k - 0.1f) * (2f * Mathf.PI) / 0.4f) * 0.5f + 1f);
 }
コード例 #6
0
    private void DrawPendulum()
    {
        //Draw Pendulum
        float deg         = sine * maxDeg;
        float rad         = M.Deg2Rad * deg;
        V3    pundulumPos = new V3(M.Sin(rad * timeScale), -M.Cos(rad * timeScale), 0);

        G.DrawWireSphere(pundulumPos + V3.left * 3, .2f);
        G.DrawLine(V3.zero + V3.left * 3, pundulumPos + V3.left * 3);
    }
コード例 #7
0
 private void DrawPlatforms()
 {
     if (!showAnims)
     {
         return;
     }
     G.color = C.white;
     G.DrawWireCube(V3.right * 2 + V3.up * M.Sin(radians * M.PI) + V3.up * -.25f, new V3(1, .5f, 0));
     G.DrawWireCube(V3.right * 3 + V3.up * M.Sin(radians * M.PI / 2) + V3.up * -.25f, new V3(1, .5f, 0));
     G.DrawWireCube(V3.right * 4 + V3.up * M.Sin(radians * M.PI / 2) * .5f + V3.up * -.25f, new V3(1, .5f, 0));
 }
コード例 #8
0
 void TIC()
 {
     cls(); for (F i = 0; i < m.Length; i++)
     {
         if (f % 10 == 0)
         {
             c++;
         }
         c = c == 0?1:c; print(m[(I)i], o + i * 6, 64 + M.Sin(i / 2 + f / M.PI / 4) * 16, c);
     }
 }
コード例 #9
0
ファイル: Easings.cs プロジェクト: Salwan/1gam_feb18_music
 /// <summary>
 /// Modeled after the piecewise exponentially-damped sine wave:
 /// y = (1/2)*sin(13pi/2*(2*x))*Math.Pow(2, 10 * ((2*x) - 1))      ; [0,0.5)
 /// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*Math.Pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
 /// </summary>
 static public float ElasticEaseInOut(float p)
 {
     if (p < 0.5f)
     {
         return(0.5f * Math.Sin(13.0f * HALFPI * (2.0f * p)) * Math.Pow(2.0f, 10.0f * ((2.0f * p) - 1.0f)));
     }
     else
     {
         return(0.5f * (Math.Sin(-13.0f * HALFPI * ((2.0f * p - 1.0f) + 1.0f)) * Math.Pow(2.0f, -10.0f * (2.0f * p - 1)) + 2.0f));
     }
 }
コード例 #10
0
 /// <summary>
 /// Modeled after the piecewise exponentially-damped sine wave:
 /// y = (1/2)*sin(13pi/2*(2*x))*Math.Pow(2, 10 * ((2*x) - 1))      ; [0,0.5)
 /// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*Math.Pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
 /// </summary>
 static public float ElasticEaseInOut(float p)
 {
     if (p < 0.5f)
     {
         return(0.5f * Math.Sin(13 * HALFPI * (2 * p)) * Math.Pow(2, 10 * ((2 * p) - 1)));
     }
     else
     {
         return(0.5f * (Math.Sin(-13 * HALFPI * ((2 * p - 1) + 1)) * Math.Pow(2, -10 * (2 * p - 1)) + 2));
     }
 }
コード例 #11
0
 public static float Out(float k)
 {
     if (k == 0)
     {
         return(0);
     }
     if (k == 1)
     {
         return(1);
     }
     return(Mathf.Pow(2f, -10f * k) * Mathf.Sin((k - 0.1f) * (2f * Mathf.PI) / 0.4f) + 1f);
 }
コード例 #12
0
 public static float In(float k)
 {
     if (k == 0)
     {
         return(0);
     }
     if (k == 1)
     {
         return(1);
     }
     return(-Mathf.Pow(2f, 10f * (k -= 1f)) * Mathf.Sin((k - 0.1f) * (2f * Mathf.PI) / 0.4f));
 }
コード例 #13
0
    private void DrawGraph()
    {
        //Draw Graph of the curves
        G.color = C.white;
        V3 offset = V3.down * 2 + V3.right * -1;

        G.DrawRay(offset + V3.up * .5f, V3.down * 1);
        G.DrawRay(offset + V3.down * .5f, V3.right * 2);

        G.color = C.gray;
        G.DrawRay(offset + V3.up * .5f, V3.right * 2);
        G.DrawRay(offset, V3.right * 2);

        G.DrawRay(offset + V3.up * .5f + V3.right * M.Repeat(radians / M.PI, 2), V3.down * 1);

        //Draw Sine
        G.color = C.red;
        offset  = V3.down * 2 + V3.right * -1;
        V3 last = new V3(0, 0, 0) + offset;

        for (int i = 1; i <= 360; i++)
        {
            V3 point = new V3((float)i / 180, M.Sin(M.Deg2Rad * i) * .5f, 0) + offset;

            G.DrawLine(last, point);
            last = point;
        }
        //Draw Cosine
        G.color = C.blue;
        offset  = V3.down * 2 + V3.right * -1;
        last    = new V3(0, .5f, 0) + offset;
        for (int i = 1; i <= 360; i++)
        {
            V3 point = new V3((float)i / 180, M.Cos(M.Deg2Rad * i) * .5f, 0) + offset;

            G.DrawLine(last, point);
            last = point;
        }
        //Draw Tangent
        if (showTan)
        {
            G.color = C.yellow;
            offset  = V3.down * 2 + V3.right * -1;
            last    = new V3(0, .5f, 0) + offset;
            for (int i = 1; i <= 360; i++)
            {
                V3 point = new V3((float)i / 180, M.Tan(M.Deg2Rad * i) * .5f, 0) + offset;

                G.DrawLine(last, point);
                last = point;
            }
        }
    }
コード例 #14
0
 /// <summary>
 /// Modeled after the piecewise overshooting cubic function:
 /// y = (1/2)*((2x)^3-(2x)*sin(2*x*pi))           ; [0, 0.5)
 /// y = (1/2)*(1-((1-x)^3-(1-x)*sin((1-x)*pi))+1) ; [0.5, 1]
 /// </summary>
 static public float BackEaseInOut(float p)
 {
     if (p < 0.5f)
     {
         float f = 2 * p;
         return(0.5f * (f * f * f - f * Math.Sin(f * PI)));
     }
     else
     {
         float f = (1 - (2 * p - 1));
         return(0.5f * (1 - (f * f * f - f * Math.Sin(f * PI))) + 0.5f);
     }
 }
コード例 #15
0
    /// <summary>
    /// Sinusoidal easing in (smooth start) between two points (a, b).
    /// </summary>
    /// <param name="a">Start point for the easing (0 by default).</param>
    /// <param name="b">End point for the easing (1 by default).</param>
    /// <param name="t">Percentage of the easing completed from 0 to 1.</param>
    public static float Sin_EaseOut(float a, float b, float t)
    {
        if (t > 1.0F)
        {
            t = 1.0F;
        }
        if (t < 0.0F)
        {
            t = 0.0F;
        }

        float x = (float)Math.Sin(t * pi / 2.0F); // F(x) =  (sin(x*pi/2)) for x in (0,1)

        return(a + x * (b - a));
    }
コード例 #16
0
        static void DrawVO(Vector2 circleCenter, float radius, Vector2 origin)
        {
            float alpha = Mathf.Atan2((origin - circleCenter).y, (origin - circleCenter).x);
            float gamma = radius / (origin - circleCenter).magnitude;
            float delta = gamma <= 1.0f ? Mathf.Abs(Mathf.Acos(gamma)) : 0;

            Draw.Debug.CircleXZ(FromXZ(circleCenter), radius, Color.black, alpha - delta, alpha + delta);
            Vector2 p1 = new Vector2(Mathf.Cos(alpha - delta), Mathf.Sin(alpha - delta)) * radius;
            Vector2 p2 = new Vector2(Mathf.Cos(alpha + delta), Mathf.Sin(alpha + delta)) * radius;

            Vector2 p1t = -new Vector2(-p1.y, p1.x);
            Vector2 p2t = new Vector2(-p2.y, p2.x);

            p1 += circleCenter;
            p2 += circleCenter;

            Debug.DrawRay(FromXZ(p1), FromXZ(p1t).normalized *100, Color.black);
            Debug.DrawRay(FromXZ(p2), FromXZ(p2t).normalized *100, Color.black);
        }
コード例 #17
0
/**
 * Tweet cart is the whole script, fit in one tweet, i.e. code length must be <= 280 characters
 *
 * Tigra tweet cart shortcuts:
 *
 * Functions:
 * TIC() is called 60 times per second.
 *
 * Variables:
 * t:  elapsed time in seconds
 * f:  frame counter
 *
 * Aliases:
 * B:  bool
 * F:  float
 * I:  int
 * M:  UnityEngine.Mathf
 * R:  UnityEngine.Random
 * S:  System.String
 * V2: UnityEngine.Vector2
 * V3: UnityEngine.Vector3
 * Z:  Tic80
 *
 * Delegates:
 * CD: circ & circb delegate
 * RD: rect & rectb delegate
 * TD: tri & trib delegate
 *
 * Beautify/minify C# online tool:
 * https://codebeautify.org/csharpviewer
 */
class Tc4 : Z { F PI2 = (F)2.0 * M.PI; I dx = 32, dy = 32, ts = 0; void TIC()
                {
                    cls(); if (dy < 0)
                    {
                        dy = 0;
                    }
                    if (dx < 0)
                    {
                        dx = 0;
                    }
                    for (F x = -dx; x < 220 + 2 * dx; x += dx)
                    {
                        for (F y = -dy; y < 136 + 2 * dy; y += dy)
                        {
                            for (F a = 0; a < PI2; a += PI2 / 8)
                            {
                                circ(x + 35 * M.Sin(a + t), y + 35 * M.Cos(a + t), 5, 15);
                            }
                        }
                    }
                }
コード例 #18
0
        /// <summary>
        /// Convert given degree rotation in given axis to orthogonal matrix rotation.
        /// </summary>
        /// <remarks>This method is much optimized than Euler(new Euler4(axis, degree))</remarks>
        public static Matrix4 Euler(int axis, float degree)
        {
            float s = Math.Sin(degree * Math.Deg2Rad), c = Math.Cos(degree * Math.Deg2Rad);
            var   m = identity;

            switch (axis)
            {
            case 0: m.ey.y = c; m.ez.z = c; m.ey.z = -s; m.ez.y = s; return(m);

            case 1: m.ex.x = c; m.ez.z = c; m.ex.z = s; m.ez.x = -s; return(m);

            case 2: m.ex.x = c; m.ey.y = c; m.ex.y = -s; m.ey.x = s; return(m);

            case 3: m.ex.x = c; m.ew.w = c; m.ex.w = -s; m.ew.x = s; return(m);

            case 4: m.ey.y = c; m.ew.w = c; m.ey.w = -s; m.ew.y = s; return(m);

            case 5: m.ez.z = c; m.ew.w = c; m.ez.w = -s; m.ew.z = s; return(m);

            default: throw new ArgumentOutOfRangeException("axis");
            }
        }
コード例 #19
0
/**
 * Tweet cart is the whole script, fit in one tweet, i.e. code length must be <= 280 characters
 *
 * Tigra tweet cart shortcuts:
 *
 * Functions:
 * TIC() is called 60 times per second.
 *
 * Variables:
 * t:  elapsed time in seconds
 * f:  frame counter
 *
 * Aliases:
 * B:  bool
 * F:  float
 * I:  int
 * M:  UnityEngine.Mathf
 * R:  UnityEngine.Random
 * S:  System.String
 * V2: UnityEngine.Vector2
 * V3: UnityEngine.Vector3
 * Z:  Tic80
 *
 * Delegates:
 * CD: circ & circb delegate
 * RD: rect & rectb delegate
 * TD: tri & trib delegate
 *
 * Beautify/minify C# online tool:
 * https://codebeautify.org/csharpviewer
 */

class Tc1 : Z { F a, b; I[] d = { 2, 3, 4, 4 }; V2[] c = new V2[4]; void TIC()
                {
                    if (a == 0)
                    {
                        c[3] = new V2(96, 24);
                    }
                    if (a++ % 10 == 0)
                    {
                        cls(); b += R.Range(-1, 1) * M.PI / 4; int i; for (i = 0; i < 3; i++)
                        {
                            c[i] = c[i + 1];
                        }
                        c[3].x += M.Sin(b) * 4; c[3].y += M.Cos(b) * 4; CD f = circb; for (i = 0; i < 4; i++)
                        {
                            if (i == 3)
                            {
                                f = circ;
                            }
                            f(c[i].x, c[i].y, d[i], 6);
                        }
                    }
                }
コード例 #20
0
ファイル: CameraComponent.cs プロジェクト: linmengjie/ET_Tank
        /// <summary>
        /// 更新相机位置
        /// </summary>
        private void UpdatePosition()
        {
            Vector3 targetPos = this.tank.Point;

            Vector3 cameraPos;

            float d = this.distance * Mathf.Cos(roll);

            float height = this.distance * Mathf.Sin(roll);

            cameraPos.x = targetPos.x + d * Mathf.Sin(rot);

            cameraPos.y = targetPos.y + height;

            cameraPos.z = targetPos.z + d * Mathf.Cos(rot);

            this.MainCamera.transform.position = cameraPos;

            this.MainCamera.transform.LookAt(this.tank.Point);


            return;
        }
コード例 #21
0
ファイル: Draw.cs プロジェクト: isoundy000/ETGame
        public void CircleXZ(Vector3 center, float radius, Color color, float startAngle = 0f, float endAngle = 2 *Mathf.PI)
        {
            int steps = 40;

#if UNITY_EDITOR
            if (gizmos)
            {
                steps = (int)Mathf.Clamp(Mathf.Sqrt(radius / UnityEditor.HandleUtility.GetHandleSize((UnityEngine.Gizmos.matrix * matrix).MultiplyPoint3x4(center))) * 25, 4, 40);
            }
#endif
            while (startAngle > endAngle)
            {
                startAngle -= 2 * Mathf.PI;
            }

            Vector3 prev = new Vector3(Mathf.Cos(startAngle) * radius, 0, Mathf.Sin(startAngle) * radius);
            for (int i = 0; i <= steps; i++)
            {
                Vector3 c = new Vector3(Mathf.Cos(Mathf.Lerp(startAngle, endAngle, i / (float)steps)) * radius, 0, Mathf.Sin(Mathf.Lerp(startAngle, endAngle, i / (float)steps)) * radius);
                Line(center + prev, center + c, color);
                prev = c;
            }
        }
コード例 #22
0
    /// <summary>
    /// Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi))
    /// </summary>
    static public float BackEaseOut(float p)
    {
        float f = (1 - p);

        return(1 - (f * f * f - f * Math.Sin(f * PI)));
    }
コード例 #23
0
 /// <summary>
 /// Modeled after the overshooting cubic y = x^3-x*sin(x*pi)
 /// </summary>
 static public float BackEaseIn(float p)
 {
     return(p * p * p - p * Math.Sin(p * PI));
 }
コード例 #24
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*Math.Pow(2, -10x) + 1
 /// </summary>
 static public float ElasticEaseOut(float p)
 {
     return(Math.Sin(-13 * HALFPI * (p + 1)) * Math.Pow(2, -10 * p) + 1);
 }
コード例 #25
0
 /// <summary>
 /// Modeled after the damped sine wave y = sin(13pi/2*x)*Math.Pow(2, 10 * (x - 1))
 /// </summary>
 static public float ElasticEaseIn(float p)
 {
     return(Math.Sin(13 * HALFPI * p) * Math.Pow(2, 10 * (p - 1)));
 }
コード例 #26
0
 /// <summary>
 /// Modeled after quarter-cycle of sine wave (different phase)
 /// </summary>
 static public float SineEaseOut(float p)
 {
     return(Math.Sin(p * HALFPI));
 }
コード例 #27
0
 /// <summary>
 /// Modeled after quarter-cycle of sine wave
 /// </summary>
 static public float SineEaseIn(float p)
 {
     return(Math.Sin((p - 1) * HALFPI) + 1);
 }
コード例 #28
0
        public override void OnGUI()
        {
            base.OnGUI();
            if (selectedObject == null)
            {
                return;
            }

            Texture currentTexture;
            float   markerX, markerY, markerRot;

            Vector3 screenPos = Player.main.viewModelCamera.WorldToScreenPoint(selectedObject.transform.position);

            //if object is on screen
            if (screenPos.z > 0 &&
                screenPos.x >= 0 && screenPos.x < Screen.width &&
                screenPos.y >= 0 && screenPos.y < Screen.height)
            {
                currentTexture = circleTexture;
                markerX        = screenPos.x;
                //subtract from height to go from bottom up to top down
                markerY   = Screen.height - screenPos.y;
                markerRot = 0;
            }
            //if object is not on screen
            else
            {
                currentTexture = arrowTexture;
                //if the object is behind us, flip across the center
                if (screenPos.z < 0)
                {
                    screenPos.x = Screen.width - screenPos.x;
                    screenPos.y = Screen.height - screenPos.y;
                }

                //calculate new position of arrow (somewhere on the edge)
                Vector3 screenCenter = new Vector3(Screen.width, Screen.height, 0) / 2f;
                Vector3 originPos    = screenPos - screenCenter;

                float angle = Mathf.Atan2(originPos.y, originPos.x) - (90 * Mathf.Deg2Rad);
                float cos   = Mathf.Cos(angle);
                float sin   = Mathf.Sin(angle);
                float m     = cos / -sin;

                Vector3 screenBounds = screenCenter * 0.9f;

                if (cos > 0)
                {
                    screenPos = new Vector3(screenBounds.y / m, screenBounds.y, 0);
                }
                else
                {
                    screenPos = new Vector3(-screenBounds.y / m, -screenBounds.y, 0);
                }
                if (screenPos.x > screenBounds.x)
                {
                    screenPos = new Vector3(screenBounds.x, screenBounds.x * m, 0);
                }
                else if (screenPos.x < -screenBounds.x)
                {
                    screenPos = new Vector3(-screenBounds.x, -screenBounds.x * m, 0);
                }

                screenPos += screenCenter;

                markerX   = screenPos.x;
                markerY   = Screen.height - screenPos.y;
                markerRot = -angle * Mathf.Rad2Deg;
            }

            float markerSizeX = currentTexture.width;
            float markerSizeY = currentTexture.height;

            GUI.matrix = Matrix4x4.Translate(new Vector3(markerX, markerY, 0)) *
                         Matrix4x4.Rotate(Quaternion.Euler(0, 0, markerRot)) *
                         Matrix4x4.Scale(new Vector3(0.5f, 0.5f, 0.5f)) *
                         Matrix4x4.Translate(new Vector3(-markerSizeX / 2, -markerSizeY / 2, 0));

            GUI.DrawTexture(new Rect(0, 0, markerSizeX, markerSizeY), currentTexture);
            GUI.matrix = Matrix4x4.identity;
        }
コード例 #29
0
 /** Returns the XZ coordinate of the involute of circle.
  * \see http://en.wikipedia.org/wiki/Involute
  */
 private static Vector3 InvoluteOfCircle(float a, float t)
 {
     return(new Vector3(a * (Mathf.Cos(t) + t * Mathf.Sin(t)), 0, a * (Mathf.Sin(t) - t * Mathf.Cos(t))));
 }
コード例 #30
0
        /// <summary>
        /// Convert degree euler to orthogonal matrix rotation individually.
        /// </summary>
        /// <remarks>
        /// This creates a rotation matrix that rotates a point by Y, Z, X, T, U, then V. In that order.
        /// </remarks>
        public static Matrix4 Euler(float x, float y, float z, float t, float u, float v)
        {
            // Multiplication matrices, in order
            float y2 = y * Math.Deg2Rad, a = Math.Cos(y2), b = Math.Sin(y2); // CW
            float z2 = z * Math.Deg2Rad, c = Math.Cos(z2), d = Math.Sin(z2); // CCW
            float x2 = x * Math.Deg2Rad, f = Math.Cos(x2), g = Math.Sin(x2); // CCW
            float t2 = t * Math.Deg2Rad, h = Math.Cos(t2), j = Math.Sin(t2); // CCW
            float u2 = u * Math.Deg2Rad, k = Math.Cos(u2), l = Math.Sin(u2); // CCW
            float v2 = v * Math.Deg2Rad, m = Math.Cos(v2), n = Math.Sin(v2); // CCW

            // Premultiplied code
            //var p1 = (b * g + a * d * f);
            //var p2 = (b * d * f + a * g);
            //var p3 = (c * j * k);
            //var p4 = -(d * j * k) + (c * f * l);
            //var p6 = (a * d * g - b * f);
            //var p7 = (a * f - b * d * g);
            //var p8 = (j * l);
            //var p9 = (c * h);
            //var p10 = (c * g);

            // This is corrected version than below (duh)
            return(new Matrix4(a * c * h,
                               -d * h,
                               b * c * h,
                               -j,
                               k * (a * d * f + b * g) - a * c * j * l,
                               c * f * k + d * j * l,
                               k * (b * d * f - a * g) - b * c * j * l,
                               -h * l,
                               -l * n * (a * d * f + b * g) + m * (a * d * g - b * f) - a * c * j * k * n,
                               c * g * m + d * j * k * n - c * f * l * n,
                               -l * n * (b * d * f - a * g) + m * (b * d * g + a * f) - b * c * j * k * n,
                               -h * k * n,
                               l * m * (a * d * f + b * g) + n * (a * d * g - b * f) + a * c * j * k * m,
                               c * f * l * m - d * j * k * m + c * g * n,
                               l * m * (b * d * f - a * g) + n * (b * d * g + a * f) + b * c * j * k * m,
                               h * k * m
                               ));

            // matrix{{ach, dh, -bch, -j}, {k(bg-adf)-acjl, cfk-djl, k(bdf+ag)+bcjl, -hl},
            // { -ln(bg-adf)+m(adg+bf)-acjkn, -cgm-cfln-djkn, -ln(bdf+ag)+m(af-bdg)+bcjkn, -hkn},
            // { lm(bg-adf)+n(adg+bf)+acjkm, cflm+djkm-cgn, lm(bdf+ag)+n(af-bdg)-bcjkm, hkm}}

            // matrix{{ach, -dh, bch, -j}, {k(adf+bg)-acjl, cfk+djl, k(bdf-ag)-bcjl, -hl},
            // { -ln(adf+bg)+m(adg-bf)-acjkn, cgm+djkn-cfln, -ln(bdf-ag)+m(bdg+af)-bcjkn, -hkn},
            // { lm(adf+bg)+n(adg-bf)+acjkm, cflm-djkm+cgn, lm(bdf-ag)+n(bdg+af)+bcjkm, hkm}}

            //return new Matrix4(
            //     a * p9,
            //     -d * h,
            //     b * p9,
            //     -j,
            //     k * p1 - a * c * p8,
            //     c * f * k + d * p8,
            //     k * p2 - b * c * p8,
            //     -h * l,
            //     m * p6 - (a * p3 + l * p1) * n,
            //     p10 * m - p4 * n,
            //     m * p7 + (b * p3 - l * p2) * n,
            //     -h * k * n,
            //     n * p6 + (a * p3 + l * p1) * m,
            //     -p10 * n + p4 * m,
            //      n * p7 - (b * p3 - l * p2) * m,
            //     h * k * m
            //  );
        }