Пример #1
0
        public void Surfaces_CreateRgbaFromDataArraySizeAndDimensionMisMatch_ThrowsException()
        {
            var systemComponents = Substitute.For <ISystemComponents>();
            var surfaceManager   = Substitute.For <IGpuSurfaceManager>();
            var properties       = Substitute.For <IStartupPropertiesCache>();

            ISurfaces surfaces = new Surfaces(properties, surfaceManager, systemComponents);

            Assert.Throws <Yak2DException>(() => { surfaces.CreateRgbaFromData(10, 10, new Vector4[90]); });
        }
Пример #2
0
        public void Surfaces_CreateFloat32FromDataNullData_ThrowsException()
        {
            var systemComponents = Substitute.For <ISystemComponents>();
            var surfaceManager   = Substitute.For <IGpuSurfaceManager>();
            var properties       = Substitute.For <IStartupPropertiesCache>();

            ISurfaces surfaces = new Surfaces(properties, surfaceManager, systemComponents);

            Assert.Throws <Yak2DException>(() => { surfaces.CreateFloat32FromData(10, 20, null); });
        }
Пример #3
0
        public void Surfaces_CreateFloat32FromDataArraySizeDimensionOfZero_ThrowsException()
        {
            var systemComponents = Substitute.For <ISystemComponents>();
            var surfaceManager   = Substitute.For <IGpuSurfaceManager>();
            var properties       = Substitute.For <IStartupPropertiesCache>();

            ISurfaces surfaces = new Surfaces(properties, surfaceManager, systemComponents);

            Assert.Throws <Yak2DException>(() => { surfaces.CreateFloat32FromData(0, 10, new float[0]); });
        }
Пример #4
0
        public void Surfaces_CreateRenderTargetInvalidDimensions_ThrowsException()
        {
            var systemComponents = Substitute.For <ISystemComponents>();
            var surfaceManager   = Substitute.For <IGpuSurfaceManager>();
            var properties       = Substitute.For <IStartupPropertiesCache>();

            ISurfaces surfaces = new Surfaces(properties, surfaceManager, systemComponents);

            Assert.Throws <Yak2DException>(() => { surfaces.CreateRenderTarget(0, 0); });
        }
Пример #5
0
        public void Surfaces_LoadTexturePathNullOrEmpty_ThrowsException()
        {
            var systemComponents = Substitute.For <ISystemComponents>();
            var surfaceManager   = Substitute.For <IGpuSurfaceManager>();
            var properties       = Substitute.For <IStartupPropertiesCache>();

            ISurfaces surfaces = new Surfaces(properties, surfaceManager, systemComponents);

            Assert.Throws <Yak2DException>(() => { surfaces.GetSurfaceDimensions(null); });
        }
Пример #6
0
        internal void OnDeserialized(StreamingContext context)
        {
            Surfaces.ForEach(s => s.units = units);
            Edges.ForEach(e => e.Brep     = this);
            Loops.ForEach(l => l.Brep     = this);
            Trims.ForEach(t => t.Brep     = this);
            Faces.ForEach(f => f.Brep     = this);

            //TODO: all the data props to the real props
        }
Пример #7
0
        internal static void Draw(SpriteBatch spriteBatch, Surfaces tileType, Rectangle currentDrawRectangle, bool heroSighted)
        {
            if (tileType == Surfaces.Void)
            {
                return;                            // No sprite for this anyway
            }
            currentSprite = tileList[tileType];
            Color tint = heroSighted ? Color.White : Color.Gray;

            spriteBatch.Draw(tileList[tileType], currentDrawRectangle, tint); // White is full color with no tinting
        }
Пример #8
0
 public Locomotor GetLocomotorForSurfaces(Surfaces surfaces)
 {
     foreach (var locomotor in _locomotors)
     {
         if ((locomotor.LocomotorTemplate.Surfaces & surfaces) != 0)
         {
             return(locomotor);
         }
     }
     return(_locomotors[0]);
 }
Пример #9
0
	  static BlackSwaptionExpiryTenorVolatilitiesTest()
	  {
		IList<SwaptionSurfaceExpiryTenorParameterMetadata> list = new List<SwaptionSurfaceExpiryTenorParameterMetadata>();
		int nData = TIME.size();
		for (int i = 0; i < nData; ++i)
		{
		  SwaptionSurfaceExpiryTenorParameterMetadata parameterMetadata = SwaptionSurfaceExpiryTenorParameterMetadata.of(TIME.get(i), TENOR.get(i));
		  list.Add(parameterMetadata);
		}
		METADATA = Surfaces.blackVolatilityByExpiryTenor("GOVT1-SWAPTION-VOL", ACT_365F).withParameterMetadata(list);
	  }
        static NormalSwaptionExpiryStrikeVolatilitiesTest()
        {
            IList <SwaptionSurfaceExpiryStrikeParameterMetadata> list = new List <SwaptionSurfaceExpiryStrikeParameterMetadata>();
            int nData = TIME.size();

            for (int i = 0; i < nData; ++i)
            {
                SwaptionSurfaceExpiryStrikeParameterMetadata parameterMetadata = SwaptionSurfaceExpiryStrikeParameterMetadata.of(TIME.get(i), STRIKE.get(i));
                list.Add(parameterMetadata);
            }
            METADATA = Surfaces.normalVolatilityByExpiryStrike("GOVT1-SWAPTION-VOL", ACT_365F).withParameterMetadata(list);
        }
        static ShiftedBlackIborCapletFloorletExpiryStrikeVolatilitiesTest()
        {
            IList <GenericVolatilitySurfaceYearFractionParameterMetadata> list = new List <GenericVolatilitySurfaceYearFractionParameterMetadata>();
            int nData = TIME.size();

            for (int i = 0; i < nData; ++i)
            {
                GenericVolatilitySurfaceYearFractionParameterMetadata parameterMetadata = GenericVolatilitySurfaceYearFractionParameterMetadata.of(TIME.get(i), SimpleStrike.of(STRIKE.get(i)));
                list.Add(parameterMetadata);
            }
            METADATA = Surfaces.blackVolatilityByExpiryStrike("CAP_VOL", ACT_365F).withParameterMetadata(list);
        }
Пример #12
0
        static NormalSwaptionExpirySimpleMoneynessVolatilitiesTest()
        {
            IList <SwaptionSurfaceExpirySimpleMoneynessParameterMetadata> list = new List <SwaptionSurfaceExpirySimpleMoneynessParameterMetadata>();
            int nData = TIME.size();

            for (int i = 0; i < nData; ++i)
            {
                SwaptionSurfaceExpirySimpleMoneynessParameterMetadata parameterMetadata = SwaptionSurfaceExpirySimpleMoneynessParameterMetadata.of(TIME.get(i), SIMPLE_MONEYNESS.get(i));
                list.Add(parameterMetadata);
            }
            METADATA = Surfaces.normalVolatilityByExpirySimpleMoneyness("GOVT1-SWAPTION-VOL", ACT_365F, MoneynessType.RATES).withParameterMetadata(list);
        }
Пример #13
0
            public ViewModel(TrackObjectBase track, TrackMapPreparationRenderer renderer)
            {
                Track    = track;
                Renderer = renderer;
                Renderer.SetFilter(this);

                Surfaces = SurfaceDescription.LoadAll(Path.Combine(track.DataDirectory, "surfaces.ini")).ToList();
                UpdateFilter(Surfaces.Where(x => x.ShouldBeVisibleOnMap()));

                _useFxaa = Renderer.UseFxaa;
                _margin  = Renderer.Margin;
                _scale   = Renderer.Scale;
            }
Пример #14
0
 public SoccerField(string name, Surfaces surface, decimal price, bool isSeven)
 {
     Name    = name;
     Surface = surface;
     Price   = price;
     IsSeven = isSeven;
     Players = IsSeven ? 14 : 10;
     //if (IsSeven)
     //{
     //    Players = 14;
     //}
     //else Players = 10;
 }
Пример #15
0
        public ConstantCalibrator(Dictionary <GazePoint, CalibrationPoint> calibrationMapping)
            : base(calibrationMapping)
        {
            double radius = 200;

            xSurface = Surfaces.CreateKernelSmoothingFittedSurface2D(
                Surfaces.SurfaceFitting2DType.KernelSmoothing,
                calibrationMapping.Select(kvp => new Surfaces.CalibrationPoint3d(kvp.Key.X, kvp.Key.Y, kvp.Value.X)),
                radius);
            ySurface = Surfaces.CreateKernelSmoothingFittedSurface2D(
                Surfaces.SurfaceFitting2DType.KernelSmoothing,
                calibrationMapping.Select(kvp => new Surfaces.CalibrationPoint3d(kvp.Key.X, kvp.Key.Y, kvp.Value.Y)),
                radius);
        }
Пример #16
0
        public void LoadTexture(Texture tex, int target = 1)
        {
            Surfaces.Clear();

            try
            {
                uint blk_dim   = Formats.blk_dims((uint)((int)tex.Format >> 8));
                uint blkWidth  = blk_dim >> 4;
                uint blkHeight = blk_dim & 0xF;

                int linesPerBlockHeight = (1 << (int)tex.BlockHeightLog2) * 8;

                uint bpp = Formats.bpps((uint)((int)tex.Format >> 8));
                for (int arrayLevel = 0; arrayLevel < tex.ArrayLength; arrayLevel++)
                {
                    int           blockHeightShift = 0;
                    List <byte[]> mips             = new List <byte[]>();
                    for (int mipLevel = 0; mipLevel < tex.TextureData[arrayLevel].Count; mipLevel++)
                    {
                        uint width  = (uint)Math.Max(1, tex.Width >> mipLevel);
                        uint height = (uint)Math.Max(1, tex.Height >> mipLevel);

                        uint size = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth) * TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight) * bpp;

                        if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight)
                        {
                            blockHeightShift += 1;
                        }

                        byte[] result = TegraX1Swizzle.deswizzle(width, height, blkWidth, blkHeight, target, bpp, (uint)tex.TileMode, (int)Math.Max(0, tex.BlockHeightLog2 - blockHeightShift), tex.TextureData[arrayLevel][mipLevel]);
                        //Create a copy and use that to remove uneeded data
                        byte[] result_ = new byte[size];
                        Array.Copy(result, 0, result_, 0, size);
                        mips.Add(result_);
                    }
                    Surfaces.Add(new Surface()
                    {
                        mipmaps = mips
                    });
                }

                Texture = tex;
            }
            catch (Exception e)
            {
                MessageBox.Show($"Failed to swizzle texture {Text}! Exception: {e}");
            }
        }
Пример #17
0
        // var polygon = Sinus(3, 50);
        // var polygon = Spiral(3, 60);
        // var polygon = Elipse(1, 0.3, 30);
        // var polygon = Elipse(0.4, 1, 10);
        // var polygon = Square.PutInside(Spiral(3, 60));
        // var polygon = Square.PutInside(Square.MultOne(0.9));
        // var polygon = Polygons.Square.PutInside(Polygons.Sinus(3, 100));
        // var shape = Polygons.Square(1).PutInside(Polygons.Spiral(10, 800).Mult(1)).MakeShape().Transform(Multiplications.Cube);
        // var polygon = Polygons.Square.PutInside(Polygons.Sinus(1.7, 1.2, 3, 300));
        // var polygon = Polygons.Elipse(1, 1, 50).PutInside(Polygons.Sinus(1.7, 1.2, 3, 300).Mult(0.8));
        // var shape = Polygons.Square(1).PutInside(Polygons.Elipse(1, 1, 50).Mult(0.7)).Fill().ToShape().Transform(Transformations.Plane);
        // var shape = Shapes.Chesss(25).Mult(2).AddZVolume(1.0 / 25).ApplyZ(Funcs3.Hyperboloid).Rotate(Rotates.Z_Y);
        // Spiral Sphere // var shape = Polygons.Elipse(1, 1, 50).PutInside(Polygons.Spiral(15, 1000).Mult(1.23)).MakeShape().Transform(Multiplications.Cube).ToSphere();
        // Sphere Heart //var shape = Polygons.Spiral(25, 4000).Mult(1.23).MakeShape().Transform(Multiplications.MoveY).Scale(1, 0.5, 1).Transform(TransformFuncs3.Heart()).Scale(0.7, 1, 1).AddVolume(0.001, 0, 0).Rotate(Rotates.Z_Y);
        // Arabica Heart // var shape = Polygons.Spiral(25, 4000).Mult(1.23).MakeShape().ApplyZ(Funcs3Z.Hyperboloid).Transform(Multiplications.MoveY).Scale(1, 0.5, 1).Transform(TransformFuncs3.Heart()).Scale(0.7, 1, 1).AddVolume(0.001, 0, 0).Rotate(Rotates.Z_Y);
        // Snake Heart // var shape = Polygons.Spiral(25, 4000).Mult(1.23).Mult(2).MakeShape(true).ApplyZ(Funcs3Z.Hyperboloid).Transform(Multiplications.MoveY).Scale(1, 0.5, 1).Transform(TransformFuncs3.Heart()).Scale(0.7, 1, 1).AddVolume(0.001, 0, 0).Rotate(Rotates.Z_Y);
        // Kershner Heart // var shape = Polygons.Square.PaveInside(Parquets.PentagonalKershner8(0.02, 1.5)).ToShape3().ToMetaShape(0.4, 40).Transform(Multiplications.MoveY).Scale(1, 0.5, 1).Transform(TransformFuncs3.Heart).Scale(0.7, 1, 1).Rotate(Rotates.Z_Y);
        // Saddle Net // var shape = Parquets.Triangles(0.1).ToShape3().Mult(2).ToMetaShape().ApplyZ(Funcs3Z.Hyperboloid).Rotate(Rotates.Z_Y);
        // Saddle Hexagon Net // var shape = Parquets.Hexagon(0.1).ToShape3().Mult(2).ToMetaShape().ApplyZ(Funcs3.Hyperboloid).Rotate(Rotates.Z_Y);
        // VualLy //var shape = Parquets.PentagonalKershner8(0.05, 1.5).ToShape3().ToMetaShape(0.5, 20).ApplyZ(Funcs3Z.Hyperboloid).Rotate(Rotates.Z_Y);
        // NeedToCut // var polygon = Polygons.Heart(1, 1, 50).Move((0,-0.1)).Mult(1.2); var shape = Paver.Pave(polygon, Parquets.PentagonalKershner8(0.03, 1.5).Mult(1)).Join(polygon.ToShape2()).ToShape3().ToMetaShape(0.5, 20).ApplyZ(Funcs3.Hyperboloid).Rotate(Rotates.Z_Y);
        // Broken Heart // var shape = Polygons.Square.Scale((2 * Math.PI-0.1, Math.PI)).PaveInside(Parquets.PentagonalKershner8(0.015, 1.5).Mult(7)).Move((Math.PI / 2, -Math.PI/2)).ToShape3().ToMetaShape(1, 20).Transform(TransformFuncs3.HeartWrap).Scale(0.4, 1, 1).Rotate(Rotates.Z_Y);
        // Kersher8 Tubes // var shape = Parquets.PentagonalKershner8ForTube(3, 1, 1.5).ToShape3().ToMetaShape(8 / 2.0, 20).AddVolumeZ(0.05).Transform(TransformFuncs3.CylinderWrapZ).Rotate(Rotates.Z_Y);
        // Kersher8 Tube // var shape = Parquets.PentagonalKershner8ForTube(3, 10, 1.5).ToShape3().ToPlaneLines(40).AddVolumeZ(0.05).Transform(TransformFuncs3.CylinderWrapZ).Rotate(Rotates.Z_Y);
        // Last Construction day ever! // var shape = Parquets.PentagonalKershner8ForTube(3, 54, 1.5).ToShape3().ToPlaneLines(40).AddVolumeZ(0.05).Transform(TransformFuncs3.CylinderWrapZ).Scale(0.1, 0.1, 1).Move(0, 0, -5).CurveZ(Funcs3.Spiral4);
        // Inside sphere // var shape = Parquets.Squares(31, 52, 0.1).Scale((Math.PI/3.1, Math.PI / 3.1)).Move((Math.PI, -Math.PI/2)).ToShape3().ToPlaneLines(20).AddVolumeZ(0.1).Transform(TransformFuncs3.SphereWrapZ).Rotate(Rotates.Z_Y);
        // Under Construction // var shape = Parquets.Triangles(12, 40, 0.1).Scale((Math.PI/3.1, 3.0.Sqrt() / 1.7)).Move((Math.PI, -Math.PI/2)).ToShape3().ToPlaneLines(20).AddVolumeZ(0.1).Transform(TransformFuncs3.HeartWrapZ).Rotate(Rotates.Z_Y).Scale(1,1,0.7);
        // Still Kersher8 // var shape = Parquets.PentagonalKershner8(0.05, 0.3).ToShape3().ToMetaShape(0.5, 20).AddVolumeZ(0.01);
        // Kershner8 flower // var shape = Parquets.PentagonalKershner8ForTube(15, 15, 1.6).Move((0, 0)).ToShape3().ToPlaneLines(5).AddVolumeZ(0.005).Transform(TransformFuncs3.Flower(1.5, 3, 7)).ApplyZ(Funcs3Z.Paraboloid).Rotate(Rotates.Z_Y).Scale(1, 0.2, 1);
        // Alive Mistake // var shape = Parquets.PentagonalKershner8ForTube(15, 15, 1.6).Move((0, 0)).ToShape3().ToPlaneLines(5).AddVolumeZ(0.005).Transform(TransformFuncs3.Flower(1.5, 3, 5)).ApplyZ(Funcs3Z.Hyperboloid).Rotate(Rotates.Z_Y).Scale(1, 0.2, 1).ApplyZ(Funcs3Z.Hyperboloid).Rotate(Rotates.Z_Y);
        // Mistake Evolution // var shape = Parquets.PentagonalKershner8ForTube(30, 30, 1.6).ToShape3().ToPlaneLines(5).AddVolumeZ(0.005).Transform(TransformFuncs3.Flower(1.5, 3, 15)).ApplyZ(Funcs3Z.Hyperboloid).Rotate(Rotates.Z_Y).Scale(1, 0.2, 1).ApplyZ(Funcs3Z.Hyperboloid).Rotate(Rotates.Z_Y);
        // Print, Kershner8 // var shape = Parquets.PentagonalKershner8(0.075, 1.5).Rotate(-1.15).ToShape3().ToMetaShape(1, 20).AddVolumeZ(0.01);
        // Print, Kershner8MugStand // var shape = Polygons.Elipse(1, 1, 50).PaveInside(Parquets.PentagonalKershner8(0.03, 1.5).Mult(1.5)).ToShape3().ToMetaShape(1, 20).AddVolumeZ(0.01);
        // Print, SpiralMugStand // var shape = Polygons.Elipse(1, 1, 100).PutInside(Polygons.Spiral(25, 6000).Mult(1.25)).MakeShape().AddVolumeZ(0.01);
        // Print, Kershner8HeartMugStand // var shape = Polygons.Heart(1, 1, 100).PaveInside(Parquets.PentagonalKershner8(0.01, 1.9).Mult(1.5)).ToShape3().ToMetaShape(0.2,50).AddVolumeZ(0.01);
        // Shamrock // var shape = Surfaces.Shamrock(400, 30).ToLines(4).Rotate(Rotates.Z_Y);
        // Kershner8 shamrock // var shape = Parquets.PentagonalKershner8ForTube(5, 75+5, 1.6).Scale((1, 0.4/3)).Move(0, -Math.PI/12).PullOnSurface90(SurfaceFuncs.Shamrock).ToLines(4).Rotate(Rotates.Z_Y);
        // Shell // var shape = Parquets.PentagonalKershner8ForTube(10, 75, 1.6).Scale((1, 0.8/3)).PullOnSurface90(SurfaceFuncs.Shell).ToLines(8).Rotate(Rotates.Z_Y);
        // See Shell // var shape = Parquets.PentagonalKershner8ForTube(10, 75, 1.6).Scale((1, 1.6/3)).PullOnSurface90(SurfaceFuncs.SeeShell).ToLines(20).Rotate(Rotates.Z_Y);
        // Dini surface // var shape = Surfaces.DiniSurface(100, 50).ToLines(2).Rotate(Rotates.Z_Y); // var shape = Surfaces.DiniSurface(120, 30).MassCentered().Normed().Move(0, 0, 1).ToLines(0.2, Color.Blue)
        // Mobius Strip // var shape = Surfaces.MobiusStrip(62, 10).ToLines(2).Rotate(Rotates.Z_Y);
        // Kershner try Mobius Strip // var shape = Parquets.PentagonalKershner8ForTube(31, 10, 1.6).Scale(0.98, 1).Move(Math.PI, -1 + 0.1).PullOnSurface(SurfaceFuncs.MobiusStrip).ToLines(1).Rotate(Rotates.Z_Y);
        // Mobius is so ...ing spectial // var shape = Surfaces.MobiusStrip(124, 20).Rotate(Rotates.Z_Y).ApplyZ(Funcs3Z.Hyperboloid).Rotate(Rotates.Z_Y).ApplyZ(Funcs3Z.Hyperboloid).ToLines(2);
        // Fractal, Tree3 // var shape = LineFractals.Tree3.CreateFractal(6).ToShape(10).Rotate(Rotates.Z_Y);
        // Never Mind // var shape = ShapeFractals.NeverMindTree(6).Rotate(Rotates.Z_Y) + Shapes.Cube;
        // Never Mind 3D // var shape = ShapeFractals.NeverMindTree3D(5).Rotate(Rotates.Z_Y) + Shapes.Cube;
        // Parabola Tree // var shape = ShapeFractals.ParabolaTree(5).Rotate(Rotates.Z_Y) + Shapes.Cube;
        // Normal Distribution // var shape = Surfaces.NormalDistribution(30, 30, 0.6, 0, 6).ToMetaShape3(3,3);
        // Normal Distribution gradient // var shape = Surfaces.NormalDistribution(55, 55, 0.5, 10, 4).ToMetaShape3(5, 5).Rotate(Rotates.Z_Y).ApplyColorGradientY(Color.DarkRed, Color.Red, Color.White);
        // Dark Heart //var shape = Parquets.Triangles(12, 40, 0.1).Scale((Math.PI / 3.1, 3.0.Sqrt() / 1.7)).Move((Math.PI, -Math.PI / 2)).ToShape3().ToPlaneLines(20).AddVolumeZ(0.1).Transform(TransformFuncs3.HeartWrapZ).Rotate(Rotates.Z_Y).Scale(1, 1, 0.7).Rotate(Rotates.Y_mZ).ApplyColorGradientY(Color.Black, Color.Black, Color.Black, Color.Black, Color.Black, Color.Black, Color.Black, Color.FromArgb(20, 20, 20), Color.Red, Color.Red);
        // Green tree // var shape = LineFractals.Tree3.CreateFractal(6).ToShape(10, true, Color.FromArgb(0, 10, 0), Color.FromArgb(0, 50, 0)).Rotate(Rotates.Z_Y);
        // Polynom // var shape = Surfaces.Cylinder(8, 61).MassCentered().Scale(0.1, 0.1, 0.1).CurveZ(Funcs3.RootPolinomY(1.0/20, new[]{ -3, -2, -0.5, 0, 1.1, 2.2, 3})) + Shapes.Cube;
        // Fourier  eagle // var shape = Polygons.FourierSeries(400, ((0.05, 0), 20), (Fourier.RotateN(1, 4), 1)).ToShape2().ToShape3().ToLines();
        // Rainbow // var shape = Surfaces.Plane(300, 30).Move(-150, -15, 0).Mult(0.0020).ApplyFn(null, v => -v.y - v.x * v.x, v=>0.005*Math.Sin(v.x*171 + v.y*750)).ToSpots3(0.05).ApplyColorGradientZ((x, y) => -x * x - y, Color.Red, Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.DarkBlue, Color.Purple, Color.Purple);
        // Barnsley Fern // var shape = IteratedFunctionSystem.BarnsleyFern(20000).Select(v => v.ToV3()).ToShape().ToTetrahedronSpots3().ApplyColor(Color.Blue);
        // Mandelbrot // var s = MandelbrotFractalSystem.GetPoints(2, 0.002, 1000).Select(v => v.ToV3()).ToShape().ToCubeSpots3(0.2).ScaleZ(15).ApplyColor(Color.Blue) + Shapes.Ball.Mult(0.1).ApplyColor(Color.Red);
        // Maze 5 5 5 // var shape = Mazes.CreateNet3Maze(5, 5, 5).ToCubeMetaShape3(10, 10, Color.Blue, Color.Red);
        // Kershner8 Maze // var shape = Mazes.CrateKershner8Maze(0.03, 1.7, -1.09, 5).ToMetaShape3(0.2, 0.5, Color.Blue, Color.Red);
        // Fantastic Kershner8 Maze // var shape = Mazes.CrateKershner8Maze(0.01, 1.7, -1.09, 5).Mult(3).Transform(TransformFuncs3.Flower(0.3, 0.3, 5)).ToLines(0.2, Color.Green);
        // Kershner8 Wow Maze // var shape = Mazes.CrateKershner8Maze(0.03, 1.7, -1.09, 5).Mult(3).Transform(TransformFuncs3.Flower(0.5,0.5,5)).ToMetaShape3(0.2, 0.5, Color.Blue, Color.Red);
        // Kershner8 Wow Maze optimized // var shape = Mazes.CrateKershner8Maze(0.003, 1.7, -1.09, 5).Mult(3).Transform(TransformFuncs3.Flower(0.3, 0.3, 5)).ToTetrahedronMetaShape3(0.1, 0.3, Color.Blue, Color.Red);
        // Mobius Maze // var shape = Surfaces.MobiusStrip(128, 20).ToMaze(0, MazeType.SimpleRandom).ToLines(2).Rotate(Rotates.Z_Y).ApplyColor(Color.FromArgb(20, 20, 20));
        // Maze with path // var (maze, path) = Parquets.PentagonalKershner8(0.01, 1.7).Rotate(-1.09).ToShape3().Mult(3).Transform(TransformFuncs3.Flower(0.3, 0.3, 5)).ToMazeWithPath(1, new[] { (6, 7), (-6, -5) });            var shape = maze.ToLines(0.2, Color.Blue) + path.ToLines(0.2, Color.Red);
        // Imposible maze // var (maze, path) = Parquets.PentagonalKershner8(0.002, 1.7).ToShape3().Mult(4).ToMazeWithPath(1, MazeType.SimpleRandom, new[] { (6, 7), (-6, -5) });             var enter = Surfaces.Sphere(10, 10).Mult(0.005).Move(path.Points3[0]).ApplyColor(Color.Black);            var exit = Surfaces.Sphere(10, 10).Mult(0.005).Move(path.Points3[^1]).ApplyColor(Color.Green);            var shape = maze.ToLines(0.2, Color.Blue) + enter + exit + path.ToLines(0.2, Color.Red); //.Transform(TransformFuncs3.Torus(1.5))
        // Gravity maze // var (maze, path) = Parquets.Squares(50, 50, 0.04).ToShape3().ApplyZ(Funcs3Z.Paraboloid).ToMazeWithPath(1, MazeType.PowerGravity);            maze = maze.Rotate(Rotates.Z_Y);           path = path.Rotate(Rotates.Z_Y);            var enter = Surfaces.Sphere(10, 10).Mult(0.01).Move(path.Points3[0]).ApplyColor(Color.Black);            var exit = Surfaces.Sphere(10, 10).Mult(0.01).Move(path.Points3[^1]).ApplyColor(Color.Green);                  var shape = maze.ToLines(1, Color.Blue) + enter + exit + path.ToLines(0.3, Color.Red);
        // Not bad font // var shape = Texter.GetText("This is not a 3d font\r\nbut\r\nthis is already not bad", 50).ToCubeSpots3(50).ApplyColorGradientY(Color.Red, Color.Red, Color.White);
        // LNT // var shape = Vectorizer.GetText("ВОЙНА И МИР\r\nТОМ ПЕРВЫЙ\r\nЧАСТЬ ПЕРВАЯ\r\nI", 100, "Times New Roman").ToLines(300, Color.Red);
        // LNT2 // var shape = Vectorizer.GetText("— Eh bien, mon prince. Gênes et Lucques ne sont plus que des apanages, des\r\nпоместья, de la famille Buonaparte. Non, je vous préviens que si vous ne me dites pas\r\nque nous avons la guerre, si vous vous permettez encore de pallier toutes les infamies,\r\ntoutes les atrocités de cet Antichrist (ma parole, j'y crois) — je ne vous connais plus,\r\nvous n'êtes plus mon ami, vous n'êtes plus мой верный раб, comme vous dites.", 100, "Times New Roman").ToLines(300, Color.Red);
        // Bird // var shape = Vectorizer.GetContentShape(settings.GetContentFileName("bird1.jpg")).ApplyZ(Funcs3Z.Paraboloid).ToLines(0.5).ApplyColorGradientY(Color.Red, Color.Red, Color.White);
        // Iguana //var shape = Vectorizer.GetContentShape(settings.GetContentFileName("iguana1.jpg")).ApplyZ(Funcs3Z.Waves).ToLines(0.5).ApplyColorGradientZ(Color.Black, Color.Black, Color.DarkBlue);
        // Dragon // var shape = Vectorizer.GetContentShape(settings.GetContentFileName("dragon4.jpg")).ApplyZ(Funcs3Z.Waves).ToLines(0.2).ApplyColorGradientZ(Color.DarkRed, Color.Black, Color.DarkRed);
        // Fourier Man // var shape = FourierShapes.Series(new Fr[] { (-3, 1), (-11, 1), (-6, 2), (-9, 1), (4, 2), (-1, 10) }).ToSingleShape();
        // Fourier Woman // var shape = FourierShapes.Series(new Fr[] { (-7, 1), (-3, 2), (-11, 1), (-6, 2), (-9, 1), (4, 2), (-1, 10) }).ToSingleShape();
        // Fourier Athlete // var shape = FourierShapes.Series(new Fr[] { (1, 1), (2, -2), (-11, 1), (-6, 2), (-9, 1), (4, 2), (-1, 10) }).ToSingleShape();
        // Fourier Perfect Man // var shape = FourierShapes.Series(new Fr[] { (1, 1), (2, -2), (-11, 1), (-6, 2), (-9, 1), (4, 3), (-1, 12) }).ToSingleShape();
        // Fourier search humans // var shape = FourierShapes.SearchSeries(new Fr[] { (-11, 1), (-6, 2), (-9, 1), (4, 2), (-1, 10) }, 1, 2, -20, 20, -20, 20);
        // Fourier Kung Fu, let's start // var shape = FourierShapes.Series(new Fr[] { (-11, 1, 0.1), (-9,1),(-6,2,0.15),(-3,2),(-1,13),(1,1),(2,-2),(4,3),(9,-1) });
        // Fourier, kung fu best // (-41, 0.25), (-11, 1, 0.1), (-9, 1), (-6, 2, 0.15), (-3, 1.8), (-1, 13), (1, 1), (2, -2), (4, 3), (9, -1) //Transform(TransformFuncs3.RotateX(0.1, 10))
        // Fourier, elephant // (10, -1), (9, 3), (4, -7), (-3, -8), (3, 5), (-9, 3), (2, 5), (-18, 3), (1, 3), (-6, -1), (200, -1), (-16, 1), (11, -2), (16, 1), (13, -2), (-8, 5), (-37, 2), (1,2), (3,4), (-2,3), (-1,5), (5,1), (16, -3),
        // Fourier, for search // (-1, 10), (17, 1), (20, -2), (200, 0.2), (-1, 4), (2, 7),

        // compositions: .ApplyZ(Funcs3Z.SphereR(1.2)); Shapes.IcosahedronSp2.Mult(0.02).ApplyColor(Color.Red); Shapes.GolfBall.Move(0.7, 1.5, 2).ToLines(1, Color.Red)

        public Shape GetExamplePolygons()
        {
            var fShape = new Fr[]
            { (-11, 1, 0.1), (-9, 1), (-6, 2, 0.15), (-3, 2), (-1, 13), (1, 1), (2, -2), (4, 3), (9, -1) };

            var mb = MandelbrotFractalSystem.GetPoints(2, 0.002, 1000);

            var mbFilled     = mb.ToPolygon().PutInside(fShape.ToShapes(1000)[0].ToPolygon().Mult(0.6).MoveX(-0.15)).ToShape(0.01).ApplyColor(Color.Green);
            var mbOutLine    = mb.ToShape().ToLines(0.2).ScaleZ(15).ApplyColor(Color.Blue);
            var frInsideLine = fShape.ToLineShape(1000, 0.2).ScaleZ(16 / 0.6).Mult(0.6).MoveX(-0.15).ApplyColor(Color.Blue);
            var cutNet       = Surfaces.Plane(100, 100).Perfecto(3).MoveX(-0.5).Cut(mb.ToPolygon()).MoveZ(-0.1).ToLines(0.5).ApplyColor(Color.Blue);

            var shape = new[] { mbFilled, mbOutLine, frInsideLine, cutNet }.ToSingleShape();

            return(shape);
        }
Пример #18
0
        public void Initialize(LocomotorSetTemplate locomotorSetTemplate)
        {
            _surfaces = Surfaces.None;

            foreach (var locomotorTemplateReference in locomotorSetTemplate.Locomotors)
            {
                var locomotorTemplate = locomotorTemplateReference.Value;

                _locomotors.Add(new Locomotor(
                                    _gameObject,
                                    locomotorTemplate,
                                    locomotorSetTemplate.Speed));

                _surfaces |= locomotorTemplate.Surfaces;
            }
        }
Пример #19
0
    public override void Begin()
    {
        Gravity = new Vector2(0, -0);

        p1 = new PhysicsObject(5, 50);
        Add(p1);

        p2 = new PhysicsObject(100, 50);
        p2.Body.Velocity = new Jypeli.Vector(-120, 10);
        p2.Position      = new Jypeli.Vector(400, 0);
        Add(p2);

        Surfaces ss = Level.CreateBorders();

        AddCollisionHandler <PhysicsObject, PhysicsObject>(p1, delegate { MessageDisplay.Add("kissa"); });
    }
    public void RespawnCoinsInMiddle(GameObject firstObject, GameObject secondObject)
    {
        bool checkHitCollision = false;

        RaycastHit2D[] hit = Physics2D.CircleCastAll(firstObject.transform.position, GetGameObjectType(ItemType.Coin).GetComponent <CircleCollider2D>().radius, (secondObject.transform.position - firstObject.transform.position), Vector2.Distance(secondObject.transform.position, firstObject.transform.position));
        for (int i = 0; i < hit.Length; i++)
        {
            tempList.Add(hit[i].collider);
            if (hit[i].collider.gameObject != firstObject.gameObject && hit[i].collider.gameObject != secondObject.gameObject)
            {
                if (hit[i].collider.transform.gameObject.layer == 12 || hit[i].collider.gameObject.tag == "Deadly" || hit[i].collider.gameObject.tag == "Surface")
                {
                    // GameObject collided = new GameObject("collided");
                    // collided.transform.position = hit[i].normal;
                    checkHitCollision = true;
                }
            }
        }

        if (!checkHitCollision)
        {
            Surfaces surface1 = firstObject.GetComponent <Surfaces>();
            Surfaces surface2 = secondObject.GetComponent <Surfaces>();
            if (surface1.alreadyRespawnedCoin || surface1.alreadyRespawnedCoin)
            {
                return;
            }
            int randomNumberOfCoins = Random.Range(3, 6);

            canRespawnCoinsMiddle = true;
            if (canRespawnCoinsMiddle)
            {
                for (int i = 1; i < randomNumberOfCoins; i++)
                {
                    Vector2 position = firstObject.transform.position + (secondObject.transform.position - firstObject.transform.position) * 1 / randomNumberOfCoins * i;

                    Vector2 offsetPosition = position + (new Vector2(secondObject.GetComponent <SpriteRenderer>().bounds.size.x, secondObject.GetComponent <SpriteRenderer>().bounds.size.y))
                                             - (new Vector2(firstObject.GetComponent <SpriteRenderer>().bounds.size.x, firstObject.GetComponent <SpriteRenderer>().bounds.size.y));
                    GameObject go = Instantiate(GetGameObjectType(ItemType.Coin), offsetPosition, Quaternion.identity, firstObject.transform.parent);
                    go.GetComponent <ObjectOverlap>().priority = 1;
                }

                canRespawnCoinsMiddle = false;
            }
        }
    }
Пример #21
0
        public GameSurfaceManager(
            ShaderManager shaders,
            Matrix4Uniform view,
            Matrix4Uniform projection)
        {
            var hex = new IndexedSurface <UVColorVertexData>()
                      .WithShader(shaders["Deferred/gSprite"])
                      .AndSettings(
                view, projection,
                new TextureUniform("diffuseTexture", new Texture(sprite("hex-diffuse.png")), TextureUnit.Texture0),
                new TextureUniform("normalTexture", new Texture(sprite("hex-normal.png")), TextureUnit.Texture1)
                );

            Surfaces.Add("hex", hex);

            SurfaceList = Surfaces.Values.ToList <Surface>().AsReadOnly();
        }
    public void SurfaceSelection(Collider2D collision)
    {
        switch (collision.gameObject.tag)
        {
        case "Sand":
            m_CurrentSurface = Surfaces.Sand;
            m_CurrentFs      = m_FootstepsSand[m_AudioClipIndex];
            break;

        case "Concrete":
            m_CurrentSurface = Surfaces.Concrete;
            m_CurrentFs      = m_FootstepsConcrete[m_AudioClipIndex];
            break;

        case "Water":
            m_CurrentSurface = Surfaces.Water;
            m_CurrentFs      = m_FootstepsWater[m_AudioClipIndex];
            break;

        case "WaterOnConcrete":
            m_CurrentSurface = Surfaces.Water;
            m_CurrentFs      = m_FootstepsWater[m_AudioClipIndex];
            break;

        case "Wood":
            m_CurrentSurface = Surfaces.Wood;
            m_CurrentFs      = m_FootstepsWood[m_AudioClipIndex];
            break;

        case "WoodInsideRoom":
            m_CurrentSurface = Surfaces.Wood;
            m_CurrentFs      = m_FootstepsWood[m_AudioClipIndex];
            break;

        case "Background":

            break;

        default:
            m_CurrentFs      = m_FootstepsGrass[m_AudioClipIndex];
            m_CurrentSurface = Surfaces.Grass;
            Debug.Log("Grass Again, Why?");
            // Debug.LogError("Error in footstep switch at FootStepsSound.cs line: 68");
            break;
        }
    }
Пример #23
0
        public GlobalScalingLocalOffsetCalibrator(Dictionary <GazePoint, CalibrationPoint> calibrationMapping)
            : base(calibrationMapping)
        {
            //Assume most of the projection can be explained globally by stretching the screen in both x and y directions separately.
            double meanGazeX = calibrationMapping.Select(kvp => kvp.Key.X).Average();

            meanScalingX = calibrationMapping
                           .Where(kvp => kvp.Key.X >= meanGazeX * .01) //Ignore any points too close to the left side of the screen for X scaling
                           .Select(kvp => kvp.Value.X / kvp.Key.X)     //Get ratio
                           .Average();
            double meanGazeY = calibrationMapping.Select(kvp => kvp.Key.Y).Average();

            meanScalingY = calibrationMapping
                           .Where(kvp => kvp.Key.Y >= meanGazeY * .01) //Ignore any points too close to the top side of the screen for Y scaling
                           .Select(kvp => kvp.Value.Y / kvp.Key.Y)     //Get ratio
                           .Average();

            //Then model the offset that needs to be applied to each of the calibration points as a local phenomenon.
            if (false)
            {
                double radius = 2000; //pixels
                xOffsetSurface = Surfaces.CreateKernelSmoothingFittedSurface2D(
                    Surfaces.SurfaceFitting2DType.KernelSmoothing,
                    calibrationMapping.Select(kvp => new Surfaces.CalibrationPoint3d(kvp.Key.X, kvp.Key.Y, kvp.Value.X - kvp.Key.X * meanScalingX)),
                    radius);
                yOffsetSurface = Surfaces.CreateKernelSmoothingFittedSurface2D(
                    Surfaces.SurfaceFitting2DType.KernelSmoothing,
                    calibrationMapping.Select(kvp => new Surfaces.CalibrationPoint3d(kvp.Key.X, kvp.Key.Y, kvp.Value.Y - kvp.Key.Y * meanScalingY)),
                    radius);
            }
            else if (false)
            {
                xOffsetSurface = Surfaces.CreateBilinearInterpolatedSurface2D(
                    calibrationMapping.Select(kvp => new Surfaces.CalibrationPoint3d(kvp.Key.X, kvp.Key.Y, kvp.Value.X - kvp.Key.X * meanScalingX))
                    );
                yOffsetSurface = Surfaces.CreateBilinearInterpolatedSurface2D(
                    calibrationMapping.Select(kvp => new Surfaces.CalibrationPoint3d(kvp.Key.X, kvp.Key.Y, kvp.Value.Y - kvp.Key.Y * meanScalingY))
                    );
            }
            else
            {
                xOffsetSurface = Surfaces.CreateZeroSurface2D();
                yOffsetSurface = Surfaces.CreateZeroSurface2D();
            }
        }
Пример #24
0
        //-------------------------------------------------------------------------
        public SurfaceMetadata createMetadata(RawOptionData capFloorData)
        {
            SurfaceMetadata metadata;

            if (capFloorData.DataType.Equals(BLACK_VOLATILITY))
            {
                metadata = Surfaces.blackVolatilityByExpiryStrike(name.Name, dayCount);
            }
            else if (capFloorData.DataType.Equals(NORMAL_VOLATILITY))
            {
                metadata = Surfaces.normalVolatilityByExpiryStrike(name.Name, dayCount);
            }
            else
            {
                throw new System.ArgumentException("Data type not supported");
            }
            return(metadata);
        }
Пример #25
0
 public override ICurve[] Intersect(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds)
 {
     if (other is PlaneSurface ps)
     {
         IDualSurfaceCurve[] dsc = GetPlaneIntersection(ps, otherBounds.Left, otherBounds.Right, otherBounds.Bottom, otherBounds.Top, 0.0);
         List <ICurve>       res = new List <ICurve>();
         for (int i = 0; i < dsc.Length; i++)
         {
             res.Add(dsc[i].Curve3D);
         }
         return(res.ToArray());
     }
     if (other is ICylinder cylo)
     {
         ICurve[] res = Surfaces.Intersect(this as ICylinder, other as ICylinder);
     }
     return(base.Intersect(thisBounds, other, otherBounds));
 }
Пример #26
0
        public CarDemo()
        {
            int alpha = 255;
            int colA = Color.FromArgb(alpha, 51, 58, 51).ToArgb();
            int colB = Color.FromArgb(alpha, 51, 102, 170).ToArgb();
            int colC = Color.FromArgb(alpha, 170, 187, 187).ToArgb();
            int colD = Color.FromArgb(alpha, 102, 153, 170).ToArgb();
            int colE = Color.FromArgb(alpha, 119, 136, 119).ToArgb();
            int colPad = Color.FromArgb(alpha, 153, 102, 51).ToArgb();

            APEngine.init((float) 1 / 4);

            Vector massLessForces = new Vector(0, 3);
            APEngine.addMasslessForce(massLessForces);

            Surfaces surfaces = new Surfaces(colA, colB, colC, colD, colE, colPad);
            APEngine.addGroup(surfaces);

            Bridge bridge = new Bridge(colB, colC, colD);
            APEngine.addGroup(bridge);

            Capsule capsule = new Capsule(colC);
            APEngine.addGroup(capsule);

            rotator = new Rotator(colB, colE);
            APEngine.addGroup(rotator);

            SwingDoor swingDoor = new SwingDoor(colC);
            APEngine.addGroup(swingDoor);

            car = new Car(colC, colE);
            APEngine.addGroup(car);

            car.addCollidable(surfaces);
            car.addCollidable(bridge);
            car.addCollidable(rotator);
            car.addCollidable(swingDoor);
            car.addCollidable(capsule);

            capsule.addCollidable(surfaces);
            capsule.addCollidable(bridge);
            capsule.addCollidable(rotator);
            capsule.addCollidable(swingDoor);
        }
Пример #27
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenLandXMLFile();

            Alignments alignments = _data.Alignments;

            if (alignments != null)
            {
                GetAlignment(alignments.Alignment[0]);
            }


            Surfaces surfaces = _data.Surfaces;

            if (surfaces != null)
            {
                GetSurfaces(surfaces);
            }
        }
        public virtual void test_presentValueSensitivityRatesStickyModel_stickyStrike()
        {
            SwaptionVolatilities volSabr    = SwaptionSabrRateVolatilityDataSet.getVolatilitiesUsd(VAL_DATE, false);
            double               impliedVol = SWAPTION_PRICER.impliedVolatility(SWAPTION_REC_LONG, RATE_PROVIDER, volSabr);
            SurfaceMetadata      blackMeta  = Surfaces.blackVolatilityByExpiryTenor("CST", VOLS.DayCount);
            SwaptionVolatilities volCst     = BlackSwaptionExpiryTenorVolatilities.of(VOLS.Convention, VOLS.ValuationDateTime, ConstantSurface.of(blackMeta, impliedVol));
            // To obtain a constant volatility surface which create a sticky strike sensitivity
            PointSensitivityBuilder        pointRec    = SWAPTION_PRICER.presentValueSensitivityRatesStickyStrike(SWAPTION_REC_LONG, RATE_PROVIDER, volSabr);
            CurrencyParameterSensitivities computedRec = RATE_PROVIDER.parameterSensitivity(pointRec.build());
            CurrencyParameterSensitivities expectedRec = FD_CAL.sensitivity(RATE_PROVIDER, (p) => SWAPTION_PRICER.presentValue(SWAPTION_REC_LONG, (p), volCst));

            assertTrue(computedRec.equalWithTolerance(expectedRec, NOTIONAL * FD_EPS * 100d));

            PointSensitivityBuilder        pointPay    = SWAPTION_PRICER.presentValueSensitivityRatesStickyStrike(SWAPTION_PAY_SHORT, RATE_PROVIDER, volSabr);
            CurrencyParameterSensitivities computedPay = RATE_PROVIDER.parameterSensitivity(pointPay.build());
            CurrencyParameterSensitivities expectedPay = FD_CAL.sensitivity(RATE_PROVIDER, (p) => SWAPTION_PRICER.presentValue(SWAPTION_PAY_SHORT, (p), volCst));

            assertTrue(computedPay.equalWithTolerance(expectedPay, NOTIONAL * FD_EPS * 100d));
        }
    public void RespawnOpalInMiddle(GameObject firstObject, GameObject secondObject)
    {
        bool checkHitCollision = false;

        RaycastHit2D[] hit = Physics2D.CircleCastAll(firstObject.transform.position, GetGameObjectType(ItemType.Opal).GetComponent <CircleCollider2D>().radius, (secondObject.transform.position - firstObject.transform.position), Vector2.Distance(secondObject.transform.position, firstObject.transform.position));
        for (int i = 0; i < hit.Length; i++)
        {
            if (hit[i].collider.gameObject != firstObject.gameObject)
            {
                if (hit[i].collider.transform.gameObject.layer == 12 || hit[i].collider.gameObject.tag == "Deadly")
                {
                    // GameObject collided = new GameObject("collided");
                    //collided.transform.position = hit[i].transform.position;
                    checkHitCollision = true;
                }
            }
        }

        if (checkHitCollision)
        {
            return;
        }


        Surfaces surface1 = firstObject.GetComponent <Surfaces>();
        Surfaces surface2 = secondObject.GetComponent <Surfaces>();

        int numberOfOpals = 1;

        if (canRespawnOpalMiddle)
        {
            for (int i = 0; i < numberOfOpals; i++)
            {
                Vector2 position       = firstObject.transform.position + (secondObject.transform.position - firstObject.transform.position) * 1 / 2;
                Vector2 offsetPosition = position + (new Vector2(secondObject.GetComponent <SpriteRenderer>().bounds.size.x, secondObject.GetComponent <SpriteRenderer>().bounds.size.y))
                                         - (new Vector2(firstObject.GetComponent <SpriteRenderer>().bounds.size.x, firstObject.GetComponent <SpriteRenderer>().bounds.size.y));
                GameObject go = Instantiate(GetGameObjectType(ItemType.Opal), offsetPosition, Quaternion.identity, firstObject.transform.parent);
                go.GetComponent <ObjectOverlap>().priority = 2;
            }

            canRespawnOpalMiddle = false;
        }
    }
Пример #30
0
        public virtual void test_createMetadata_normal()
        {
            SurfaceIborCapletFloorletVolatilityBootstrapDefinition @base = SurfaceIborCapletFloorletVolatilityBootstrapDefinition.of(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, LINEAR, DOUBLE_QUADRATIC);
            RawOptionData capData = RawOptionData.of(ImmutableList.of(Period.ofYears(1), Period.ofYears(5)), DoubleArray.of(0.005, 0.01, 0.015), ValueType.STRIKE, DoubleMatrix.copyOf(new double[][]
            {
                new double[] { 0.15, 0.12, 0.13 },
                new double[] { 0.1, Double.NaN, 0.09 }
            }), ValueType.NORMAL_VOLATILITY);
            IList <GenericVolatilitySurfacePeriodParameterMetadata> list = new List <GenericVolatilitySurfacePeriodParameterMetadata>();

            list.Add(GenericVolatilitySurfacePeriodParameterMetadata.of(Period.ofYears(1), SimpleStrike.of(0.005)));
            list.Add(GenericVolatilitySurfacePeriodParameterMetadata.of(Period.ofYears(1), SimpleStrike.of(0.01)));
            list.Add(GenericVolatilitySurfacePeriodParameterMetadata.of(Period.ofYears(1), SimpleStrike.of(0.015)));
            list.Add(GenericVolatilitySurfacePeriodParameterMetadata.of(Period.ofYears(5), SimpleStrike.of(0.005)));
            list.Add(GenericVolatilitySurfacePeriodParameterMetadata.of(Period.ofYears(5), SimpleStrike.of(0.015)));
            SurfaceMetadata expected = Surfaces.normalVolatilityByExpiryStrike(NAME.Name, ACT_ACT_ISDA).withParameterMetadata(list);
            SurfaceMetadata computed = @base.createMetadata(capData);

            assertEquals(computed, expected);
        }
Пример #31
0
        private void fixSurfaces()
        {
            if (!fixedSurfaces)
            {
                Color origFill    = Water.FillColor;
                Color origSurface = Water.SurfaceColor;

                changeColor(fillColorField, origFill, fillColor);
                changeColor(surfaceColorField, origSurface, surfaceColor);

                bool hasTop    = Surfaces.Contains(TopSurface);
                bool hasBottom = Surfaces.Contains(BottomSurface);

                Surfaces.Clear();

                if (hasTop)
                {
                    TopSurface = new Water.Surface(Position + new Vector2(Width / 2f, 8f), new Vector2(0.0f, -1f), Width, Height);
                    Surfaces.Add(TopSurface);

                    actualTopSurface = TopSurface;
                    dummyTopSurface  = new Water.Surface(Position + new Vector2(Width / 2f, 8f), new Vector2(0.0f, -1f), Width, Height);
                }

                if (hasBottom)
                {
                    BottomSurface = new Water.Surface(Position + new Vector2(Width / 2f, Height - 8f), new Vector2(0.0f, 1f), Width, Height);
                    Surfaces.Add(BottomSurface);

                    actualBottomSurface = BottomSurface;
                    dummyBottomSurface  = new Water.Surface(Position + new Vector2(Width / 2f, Height - 8f), new Vector2(0.0f, 1f), Width, Height);
                }

                fixedSurfaces  = true;
                actualSurfaces = Surfaces;
                emptySurfaces  = new List <Surface>();

                changeColor(fillColorField, fillColor, origFill);
                changeColor(surfaceColorField, surfaceColor, origSurface);
            }
        }