Esempio n. 1
0
        private Vector2 GetMouseUnitCoordinates(Point mouseWindowCoordinates)
        {
            float xGLCoordinate = Mathematics.InverseLerp(mouseWindowCoordinates.X, 0, width);
            float yGLCoordinate = Mathematics.InverseLerp(mouseWindowCoordinates.Y, 0, height);

            return(new Vector2(xGLCoordinate, yGLCoordinate));
        }
        private Vector3 GetMousePositionUnitCoordinates(Point mousePosition)
        {
            float mousePositionInverseLerpX = Mathematics.InverseLerp(mousePosition.X, 0, width);
            float mousePositionInverseLerpY = Mathematics.InverseLerp(mousePosition.Y, 0, height);

            //return new Vector3(Mathematics.Lerp(mousePositionInverseLerpX, -1, 1), -Mathematics.Lerp(mousePositionInverseLerpY, -1, 1), 0);
            return(new Vector3(mousePositionInverseLerpX, mousePositionInverseLerpY, 0));
        }
Esempio n. 3
0
        //prepare the shader for the given entity.
        private void PrepareInstance(Node node)
        {
            Transform transform            = new Transform(node.position, 0, 0, 0, 1);
            Matrix4   transformationMatrix = Mathematics.CreateTransformationMatrix(transform.position, transform.xAxisRotation, transform.yAxisRotation, transform.zAxisRotation, transform.scale);

            nodeShader.LoadTransformationMatrix(transformationMatrix);
            nodeShader.LoadDynamicColor(node.color);
        }
Esempio n. 4
0
        //prepare the shader for the given entity.
        private void PrepareInstance(Function function)
        {
            Transform transform            = new Transform(function.position, 0, 0, 0, 1);
            Matrix4   transformationMatrix = Mathematics.CreateTransformationMatrix(transform.position, transform.xAxisRotation, transform.yAxisRotation, transform.zAxisRotation, transform.scale);

            graphingShader.LoadTransformationMatrix(transformationMatrix);
            graphingShader.LoadDynamicColor(function.color);
        }
Esempio n. 5
0
        private void PrepareInstance(Data data)
        {
            Transform transform            = new Transform(data.position, data.rotation.X, data.rotation.Y, data.rotation.Z, 1);
            Matrix4   transformationMatrix = Mathematics.CreateTransformationMatrix(transform.position, transform.xAxisRotation, transform.yAxisRotation, transform.zAxisRotation, transform.scale);

            graphingShader.LoadTransformationMatrix(transformationMatrix);
            graphingShader.LoadDynamicColor(new Vector3(1, 1, 1));
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Mathematics     m              = new Mathematics();
            IArithmatic     arithmatic     = new Mathematics(); // upcasting
            IMoreArithmatic moreArithmatic = new Mathematics(); // upcasting

            Console.WriteLine($"Substraction result  { arithmatic.Subs(45, 6)}");
            Console.WriteLine($"Substraction more result  { moreArithmatic.Subs(45, 6)}");
            Console.WriteLine($"Addition result {m.Add(12, 23, 25, 56)}");
            // Named parameters
            Console.WriteLine($"Division result {m.Divide(deno:9, num:36)}");
        }
        private static int Calculate(Commands command, int first, int second)
        {
            switch (command)
            {
            case Commands.add:
                return(Mathematics.Add(first, second));

            case Commands.sub:
                return(Mathematics.Sub(first, second));

            default:
                throw new InvalidOperationException("Unknown command in calculator");
            }
        }
        private Vector3 GetMousePositionCartesianCoordinates(Vector3 mousePositionUnitCoordinates)
        {
            //we will get the mouse position by linearly interpolating between the cartesian coordinates of the frustrum edges. we will consider the plane of the frustrum at the graphical analysis location.
            float zDistance = Math.Abs(camera.position.Z - iterativeFunction.position.Z);

            //frustrum width, height:
            float frustrumHalfHeight = zDistance * Convert.ToSingle(Math.Tan(fieldOfView * 0.5f));
            float frustrumHalfWidth  = frustrumHalfHeight * ((float)width / height);

            float leftScreenEdge   = camera.position.X - frustrumHalfWidth;
            float rightScreenEdge  = camera.position.X + frustrumHalfWidth;
            float bottomScreenEdge = camera.position.Y - frustrumHalfHeight;
            float topScreenEdge    = camera.position.Y + frustrumHalfHeight;

            return(new Vector3(Mathematics.Lerp(mousePositionUnitCoordinates.X, leftScreenEdge, rightScreenEdge), -Mathematics.Lerp(mousePositionUnitCoordinates.Y, bottomScreenEdge, topScreenEdge), 0));
        }
Esempio n. 9
0
        //determine and load a transformation matrix that manipulates the complex coordinates of the quad.
        private void PrepareInstance(Vector2 mousePositionUnitCoordinates, float mouseWheelDelta, Fractal fractal)
        {
            float   stepPercent          = 1 - (2 * mouseWheelDelta / 100f);
            Vector2 mousePositionComplex = new Vector2(Mathematics.Lerp(mousePositionUnitCoordinates.X, fractal.domain[0].X, fractal.domain[1].X), -Mathematics.Lerp(mousePositionUnitCoordinates.Y, fractal.domain[0].Y, fractal.domain[3].Y));



            Vector2 bottomLeft  = Mathematics.Lerp(stepPercent, mousePositionComplex, fractal.domain[0]);
            Vector2 bottomRight = Mathematics.Lerp(stepPercent, mousePositionComplex, fractal.domain[1]);
            Vector2 topRight    = Mathematics.Lerp(stepPercent, mousePositionComplex, fractal.domain[2]);
            Vector2 topLeft     = Mathematics.Lerp(stepPercent, mousePositionComplex, fractal.domain[3]);

            float xScale = Math.Abs(bottomRight.X - bottomLeft.X);
            float yScale = Math.Abs(topLeft.Y - bottomLeft.Y);

            Matrix4 transformationMatrix = Mathematics.CreateTransformationMatrix(new Vector3(bottomLeft.X, bottomLeft.Y, 0), xScale, yScale);

            mandelbrotShader.LoadTransformationMatrix(transformationMatrix);

            fractal.domain[0] = bottomLeft;
            fractal.domain[1] = bottomRight;
            fractal.domain[2] = topRight;
            fractal.domain[3] = topLeft;
        }
        public void LoadViewMatrix(Camera camera)
        {
            Matrix4 viewMatrix = Mathematics.CreateViewMatrix(camera);

            LoadUniform(locationViewMatrix, viewMatrix);
        }
Esempio n. 11
0
 public CalculatorService(Mathematics mathematic, IUserInterface userInterface)
 {
     // Constructor injection of services
     this.mathematic    = mathematic;
     this.userInterface = userInterface;
 }