public static double[] daub2_matrix(int n) //****************************************************************************80 // // Purpose: // // DAUB2_MATRIX returns the DAUB2 matrix. // // Discussion: // // The DAUB2 matrix is the Daubechies wavelet transformation matrix // with 2 coefficients. // // The DAUB2 matrix is also known as the Haar matrix. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 10 May 2012 // // Author: // // John Burkardt // // Parameters: // // Input, int N, the order of the matrix. // N must be at least 2 and a multiple of 2. // // Output, double DAUB2_MATRIX[N*N], the matrix. // { int i; if (n < 2 || n % 2 != 0) { Console.WriteLine(""); Console.WriteLine("DAUB2_MATRIX - Fatal error!"); Console.WriteLine(" Order N must be at least 2 and a multiple of 2."); return(null); } double[] a = typeMethods.r8mat_zero_new(n, n); double[] c = Coefficients.daub_coefficients(2); for (i = 0; i < n - 1; i += 2) { a[i + i * n] = c[0]; a[i + (i + 1) * n] = c[1]; a[i + 1 + i * n] = c[1]; a[i + 1 + (i + 1) * n] = -c[0]; } return(a); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; Vector2D[] mainhullvertecies = new Vector2D[] { //new Vector2D(60,0), new Vector2D(60, 8), new Vector2D(0, 15), new Vector2D(-40, 15), new Vector2D(-40, -15), new Vector2D(0, -15), new Vector2D(60, -8) }; List <Coefficients> ceos = new List <Coefficients>(); List <IGeometry2D> goes = new List <IGeometry2D>(); ceos.Add(DefaultCoefficients); goes.Add(new Polygon2D(ALVector2D.Zero, mainhullvertecies)); float width = 70; for (int pos = -30; pos < 60; pos += 20) { width -= 5; ceos.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(pos, 0)), Polygon2D.FromRectangle(width, 10))); } DefaultShape = new RigidBodyTemplate(9, 947.32712172484457f, goes.ToArray(), ceos.ToArray()); DefaultShape.BalanceBody(); ////DefaultShape.CalcInertiaMultiplier(.1f); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; Vector2D[] engineconevertecies = new Vector2D[] { new Vector2D(30, 10), new Vector2D(-30, 40), new Vector2D(-30, -40), new Vector2D(30, -10) }; Vector2D offset = Polygon2D.CalcCentroid(engineconevertecies); OperationHelper.ArrayRefOp <Vector2D, Vector2D, Vector2D>( engineconevertecies, ref offset, engineconevertecies, Vector2D.Subtract); //engineconevertecies = Vector2D.Translate(-offset, engineconevertecies); IGeometry2D mainhull = new Polygon2D(ALVector2D.Zero, Polygon2D.FromRectangle(80, 10)); IGeometry2D engine = new Polygon2D(new ALVector2D(0, new Vector2D(-30, 0)), Polygon2D.FromNumberofSidesAndRadius(10, 40)); IGeometry2D enginecone = new Polygon2D(new ALVector2D(0, offset), engineconevertecies); DefaultShape = new RigidBodyTemplate(12, 1231.9384791047398f, new IGeometry2D[] { engine, mainhull, enginecone }, new Coefficients[] { DefaultCoefficients, DefaultCoefficients, DefaultCoefficients }); DefaultShape.BalanceBody(); //////DefaultShape.CalcInertiaMultiplier(.1f); }
static void InitShape() { Coefficients coe = TimeWarp.Coefficients; Vector2D[] bulletverticies = new Vector2D[] { new Vector2D(30, 10), new Vector2D(-10, 10), new Vector2D(0, -10), new Vector2D(10, -10), }; List <IGeometry2D> goes = new List <IGeometry2D>(); List <Coefficients> coes = new List <Coefficients>(); for (int pos = 0; pos < 4; ++pos) { goes.Add(new Polygon2D( new ALVector2D(MathHelper.PI * .5f * pos, Vector2D.FromLengthAndAngle(10, MathHelper.PI * .5f * pos)), bulletverticies)); coes.Add(coe); } DefaultShape = new RigidBodyTemplate(.9f, 429.46676883367536f, goes.ToArray(), coes.ToArray()); //DefaultShape.BalanceBody(); ////DefaultShape.CalcInertiaMultiplier(.1f); }
private static Range GetRange(Coefficients typeOfCoef, int decompositionLevel, int width, int height) { int decompositionCoef = Convert.ToInt32(Math.Pow(2, decompositionLevel)); Range range = new Range(); switch (typeOfCoef) { case Coefficients.Approximation: range.Width.StartIndex = 0; range.Height.StartIndex = 0; break; case Coefficients.Horizontal: range.Width.StartIndex = width / decompositionCoef; range.Height.StartIndex = 0; break; case Coefficients.Vertical: range.Width.StartIndex = 0; range.Height.StartIndex = height / decompositionCoef; break; case Coefficients.Diagonal: range.Width.StartIndex = width / decompositionCoef; range.Height.StartIndex = height / decompositionCoef; break; default: range.Width.StartIndex = 0; range.Height.StartIndex = 0; break; } return(range); }
private void CreateWalls() { var wallCoff = new Coefficients(0.8f, 0.95f); var wallLife = new Lifespan(); var flrState = new PhysicsState(new ALVector2D((float)0.0, ((float)ActualWidth) * ((float)0.5), (float)ActualHeight + 100.0)); var flrShape = new PolygonShape(VertexHelper.CreateRectangle(ActualWidth, 200), 2); var bdyFloor = new Body(flrState, flrShape, float.PositiveInfinity, wallCoff, wallLife); var ceiState = new PhysicsState(new ALVector2D((float)0.0, ((float)ActualWidth) * ((float)0.5), -100.0)); var ceiShape = new PolygonShape(VertexHelper.CreateRectangle(ActualWidth, 200), 2); var bdyCeiling = new Body(ceiState, ceiShape, float.PositiveInfinity, wallCoff, wallLife); var lwlState = new PhysicsState(new ALVector2D((float)0.0, -100.0, ((float)ActualHeight) * ((float)0.5))); var lwlShape = new PolygonShape(VertexHelper.CreateRectangle(200, ActualHeight), 2); var bdyLeftWall = new Body(lwlState, lwlShape, float.PositiveInfinity, wallCoff, wallLife); var rwlState = new PhysicsState(new ALVector2D((float)0.0, (float)ActualWidth + 100.0, ((float)ActualHeight) * ((float)0.5))); var rwlShape = new PolygonShape(VertexHelper.CreateRectangle(200, ActualHeight), 2); var bdyRightWall = new Body(rwlState, rwlShape, float.PositiveInfinity, wallCoff, wallLife); engine.AddBody(bdyFloor); engine.AddBody(bdyCeiling); engine.AddBody(bdyLeftWall); engine.AddBody(bdyRightWall); }
public Expression Factor() { // Check if there is a simple factor of x. if (this[0].EqualsZero()) { return(Product.New(variable, new Polynomial(Coefficients.Where(i => i.Key != 0).ToDictionary(i => i.Key - 1, i => i.Value), variable).Factor()).Evaluate()); } DefaultDictionary <Expression, int> factors = new DefaultDictionary <Expression, int>(0); switch (Degree) { //case 2: // Expression a = this[2]; // Expression b = this[1]; // Expression c = this[0]; // // D = b^2 - 4*a*c // Expression D = Add.New(Multiply.New(b, b), Multiply.New(-4, a, c)); // factors[Binary.Divide(Add.New(Unary.Negate(b), Call.Sqrt(D)), Multiply.New(2, a))] += 1; // factors[Binary.Divide(Add.New(Unary.Negate(b), Call.Sqrt(D)), Multiply.New(2, a))] += 1; // break; default: return(this); } // Assemble expression from factors. //return Multiply.New(factors.Select(i => Power.New(Binary.Subtract(x, i.Key), i.Value))); }
static void InitShapes() { DefaultCoefficients = new Coefficients(1.1f, .2f, .2f); int length = 6; Templates = new RigidBodyTemplate[length]; List <Vector2D> vertexes = new List <Vector2D>(); for (int pos = 0; pos < length; ++pos) { int numberofSides = rand.Next(5, 10); float radius = 20 + (float)rand.NextDouble() * 20; Vector2D[] poly = Polygon2D.FromNumberofSidesAndRadius(numberofSides, radius); vertexes.AddRange(poly); for (int numbertoRemove = rand.Next(0, numberofSides - 4); numbertoRemove > 0; --numbertoRemove) { vertexes.RemoveAt(rand.Next(0, vertexes.Count)); } Polygon2D polly = new Polygon2D(ALVector2D.Zero, poly); poly = Polygon2D.MakeCentroidOrigin(vertexes.ToArray()); MassInertia mi = MassInertia.FromSolidCylinder(1 + (float)rand.NextDouble() * 2, polly.BoundingRadius); Templates[pos] = new RigidBodyTemplate(mi, new IGeometry2D[] { polly }, new Coefficients[] { DefaultCoefficients }); vertexes.Clear(); } }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; List <IGeometry2D> goes = new List <IGeometry2D>(); List <Coefficients> coes = new List <Coefficients>(); Vector2D[] mainhullvertecies = new Vector2D[] { new Vector2D(10, 10), new Vector2D(0, 40), new Vector2D(-10, 47), new Vector2D(-50, 20), new Vector2D(-60, 5), new Vector2D(-60, -5), new Vector2D(-50, -20), new Vector2D(-10, -47), new Vector2D(0, -40), new Vector2D(10, -10) }; goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(0, 0)), mainhullvertecies)); coes.Add(DefaultCoefficients); //goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(-10, 0)), new Polygon2D(8, 40))); //coes.Add(DefaultCoefficients); DefaultShape = new RigidBodyTemplate(20, 728.5412f, goes.ToArray(), coes.ToArray()); DefaultShape.BalanceBody(); //DefaultShape.CalcInertiaMultiplier(.1f); }
public override byte[] GetAsBytes() { MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); bw.Write(Endian_swap(_id)); bw.Write(Endian_swap(_version)); bw.Write(Endian_swap(_flags)); bw.Write(Endian_swap(_sizeInBytes)); bw.Write(Endian_swap(_coefficientSetCount)); for (int i = 0; i < _coefficientSetCount; i++) { Coefficients c = _coefficients[i]; bw.Write(Endian_swap(c.Kr0)); bw.Write(Endian_swap(c.Kr1)); bw.Write(Endian_swap(c.Kr2)); bw.Write(Endian_swap(c.Kr3)); } bw.Write(Endian_swap(_Cx)); bw.Write(Endian_swap(_Cy)); bw.Flush(); ms.Flush(); byte[] ret = ms.ToArray(); bw.Close(); bw.Dispose(); return(ret); }
/// <summary> /// Main method for calculating the wall coefficients. /// </summary> /// <returns>Wall coefficients.</returns> private Coefficients CalculateCoefficients() { assignedAcousticElements = new List <List <GameObject> >(); for (int i = 0; i < 6; i++) { assignedAcousticElements.Add(new List <GameObject>()); } GameObject[] acousticElements = GameObject.FindGameObjectsWithTag("Acoustic Element"); foreach (GameObject acousticElement in acousticElements) { AssignElementToWall(acousticElement); } GameObject frontW = GameObject.Find("Front Wall"); GameObject backtW = GameObject.Find("Back Wall"); GameObject leftW = GameObject.Find("Left Wall"); GameObject rightW = GameObject.Find("Right Wall"); GameObject floor = GameObject.Find("Floor"); GameObject ceiling = GameObject.Find("Ceiling"); Coefficients c = new Coefficients(); c.frontWall = CalculateWallCoefficient(frontW, assignedAcousticElements[0]); c.backWall = CalculateWallCoefficient(backtW, assignedAcousticElements[1]); c.leftWall = CalculateWallCoefficient(leftW, assignedAcousticElements[2]); c.rightWall = CalculateWallCoefficient(rightW, assignedAcousticElements[3]); c.floor = CalculateWallCoefficient(floor, assignedAcousticElements[4]); c.ceiling = CalculateWallCoefficient(ceiling, assignedAcousticElements[5]); c.isReflection = false; return(c); }
/// <summary> /// Constructor for the <c>Room</c> struct. /// </summary> /// <param name="dimension">Dimensions of the room</param> /// <param name="coefficients">Coefficients present in the room</param> /// <param name="reverberationTime">The room's reverberation time</param> public Room(Dimension dimension, Coefficients coefficients, float reverberationTime = -1) { this.dimension = dimension; this.coefficients = coefficients; this.reverberationTime = reverberationTime; this.useReverberationTime = false; }
private static double CalculateRatio(List <ScatterData> datas, List <int> waveLengths) { var R11 = datas[0].DetectedPhotons1 / datas[0].DetectedPhotons2; var R22 = datas[1].DetectedPhotons1 / datas[1].DetectedPhotons2; var R33 = datas[2].DetectedPhotons1 / datas[2].DetectedPhotons2; var R12 = R11 / R22; var R13 = R11 / R33; var alpha12 = Math.Log(R12); var alpha13 = Math.Log(R13); var alpha1 = Coefficients.ObtainAbsorptionCoefficients((uint)waveLengths[0]); var alpha2 = Coefficients.ObtainAbsorptionCoefficients((uint)waveLengths[1]); var alpha3 = Coefficients.ObtainAbsorptionCoefficients((uint)waveLengths[2]); var alphaD1 = alpha1.AbsorptionBlood; var alphaD2 = alpha2.AbsorptionBlood; var alphaD3 = alpha3.AbsorptionBlood; var alphaO1 = alpha1.AbsorptionOxygenatedBlood; var alphaO2 = alpha2.AbsorptionOxygenatedBlood; var alphaO3 = alpha3.AbsorptionOxygenatedBlood; var topLine = alpha12 * (alphaD3 + alphaD1) - alpha13 * (alphaD1 + alphaD2); var bottomLine = alpha13 * (alpha1.AbsorptionOxygenatedBlood - alpha2.AbsorptionOxygenatedBlood + alpha1.AbsorptionBlood - alpha2.AbsorptionBlood) - alpha12 * (alpha1.AbsorptionOxygenatedBlood + alpha3.AbsorptionOxygenatedBlood - alpha1.AbsorptionBlood - alpha3.AbsorptionBlood); var ratio = Math.Sqrt(Math.Pow(topLine / bottomLine, 2)); return(ratio); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; List <IGeometry2D> goes = new List <IGeometry2D>(); List <Coefficients> coes = new List <Coefficients>(); Vector2D[] engineconevertecies = new Vector2D[] { new Vector2D(-50, 10), new Vector2D(-100, 20), new Vector2D(-100, -20), new Vector2D(-50, -10) }; Vector2D offset = Polygon2D.CalcCentroid(engineconevertecies); //engineconevertecies = Vector2D.Translate( -offset,engineconevertecies); OperationHelper.ArrayRefOp <Vector2D, Vector2D, Vector2D>( engineconevertecies, ref offset, engineconevertecies, Vector2D.Subtract); goes.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromRectangle(20, 150))); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(-100, 0)), Polygon2D.FromNumberofSidesAndRadius(10, 20))); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(0, offset), engineconevertecies)); coes.Add(DefaultCoefficients); DefaultShape = new RigidBodyTemplate(18, 3383.9114375372737f, goes.ToArray(), coes.ToArray()); DefaultShape.BalanceBody(); ////DefaultShape.CalcInertiaMultiplier(.1f); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; List <IGeometry2D> goes = new List <IGeometry2D>(); List <Coefficients> coes = new List <Coefficients>(); Vector2D[] hullvertecies = new Vector2D[] { new Vector2D(30, 13), new Vector2D(0, 18), new Vector2D(-30, 20), new Vector2D(-30, -20), new Vector2D(0, -18), new Vector2D(30, -13) }; goes.Add(new Polygon2D(new ALVector2D(0, hullvertecies[0]), Polygon2D.FromNumberofSidesAndRadius(8, 12))); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(0, hullvertecies[5]), Polygon2D.FromNumberofSidesAndRadius(8, 12))); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(0, hullvertecies[2]), Polygon2D.FromNumberofSidesAndRadius(8, 12))); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(0, hullvertecies[3]), Polygon2D.FromNumberofSidesAndRadius(8, 12))); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(ALVector2D.Zero, hullvertecies)); coes.Add(DefaultCoefficients); DefaultShape = new RigidBodyTemplate(7, 771.453f, goes.ToArray(), coes.ToArray()); DefaultShape.BalanceBody(); //DefaultShape.CalcInertiaMultiplier(.1f); }
public void ObtainScatteringCoefficientsTest() { const uint testWavelength1 = 660; const uint testWavelength2 = 940; var validReturnData1 = new ScatteringCoefficients() { MuSkin = 31.004324624854842, MuBone = 18.771740745896697, MuMuscle = 8.643699764668847 }; var validReturnData2 = new ScatteringCoefficients { MuSkin = 18.757697501740985, MuBone = 14.572647582340004, MuMuscle = 5.139623591212953 }; var coefficients = Coefficients.ObtainScatteringCoefficients(testWavelength1); Assert.Equal(validReturnData1.MuSkin, coefficients.MuSkin); Assert.Equal(validReturnData1.MuBone, coefficients.MuBone); Assert.Equal(validReturnData1.MuMuscle, coefficients.MuMuscle); coefficients = Coefficients.ObtainScatteringCoefficients(testWavelength2); Assert.Equal(validReturnData2.MuSkin, coefficients.MuSkin); Assert.Equal(validReturnData2.MuBone, coefficients.MuBone); Assert.Equal(validReturnData2.MuMuscle, coefficients.MuMuscle); }
public async Task <IActionResult> PutCoefficients([FromRoute] int id, [FromBody] Coefficients coefficients) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != coefficients.Id) { return(BadRequest()); } _context.Entry(coefficients).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CoefficientsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; Vector2D[] mainhullvertecies = new Vector2D[] { new Vector2D(10, 15), new Vector2D(-40, 20), new Vector2D(-40, -20), new Vector2D(10, -15) }; Vector2D[] leftWingvertecies = new Vector2D[] { new Vector2D(40, 10), new Vector2D(-30, 2), new Vector2D(-50, -30), new Vector2D(-40, -30) }; int length = leftWingvertecies.Length; Vector2D[] RightWingvertecies = new Vector2D[] { new Vector2D(-40, 30), new Vector2D(-50, 30), new Vector2D(-30, -2), new Vector2D(40, -10) }; IGeometry2D mainhull = new Polygon2D(ALVector2D.Zero, mainhullvertecies); IGeometry2D leftWing = new Polygon2D(new ALVector2D(0, new Vector2D(-10, -20)), leftWingvertecies); IGeometry2D RightWing = new Polygon2D(new ALVector2D(0, new Vector2D(-10, 20)), RightWingvertecies); DefaultShape = new RigidBodyTemplate(13, 869.439914791763f, new IGeometry2D[] { mainhull, RightWing, leftWing }, new Coefficients[] { DefaultCoefficients, DefaultCoefficients, DefaultCoefficients }); DefaultShape.BalanceBody(); //DefaultShape.CalcInertiaMultiplier(.1f); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; List <IGeometry2D> geometries = new List <IGeometry2D>(); List <Coefficients> coefficients = new List <Coefficients>(); float da = MathHelper.PI * 2 / 5; float podlength = 50; for (float angle = 0; angle < MathHelper.PI * 2; angle += da) { Vector2D direction = Vector2D.Rotate(angle - MathHelper.PI, Vector2D.XAxis); if (angle == 0) { geometries.Add(new Polygon2D(new ALVector2D(angle - MathHelper.PI, direction * .3f * podlength), Polygon2D.FromRectangle(9, podlength * .6f))); geometries.Add(new Polygon2D(new ALVector2D(0, direction * podlength * .6f), Polygon2D.FromNumberofSidesAndRadius(8, 10))); } else { geometries.Add(new Polygon2D(new ALVector2D(angle - MathHelper.PI, direction * .5f * podlength), Polygon2D.FromRectangle(9, podlength))); geometries.Add(new Polygon2D(new ALVector2D(0, direction * podlength), Polygon2D.FromNumberofSidesAndRadius(8, 10))); } coefficients.Add(DefaultCoefficients); coefficients.Add(DefaultCoefficients); } geometries.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(10, 15))); coefficients.Add(DefaultCoefficients); DefaultShape = new RigidBodyTemplate(16, 1569.670392957858f, geometries.ToArray(), coefficients.ToArray()); DefaultShape.BalanceBody(); // ////DefaultShape.CalcInertiaMultiplier(.1f); }
static void InitShape() { Coefficients coe = TimeWarp.Coefficients; List <IGeometry2D> goes = new List <IGeometry2D>(); List <Coefficients> coes = new List <Coefficients>(); goes.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(6, 15))); coes.Add(coe); DefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(.4f, 15), goes.ToArray(), coes.ToArray()); //DefaultShape.BalanceBody(); ////DefaultShape.CalcInertiaMultiplier(.1f); goes.Clear(); coes.Clear(); goes.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(6, 9))); coes.Add(coe); SubDefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(.01f, 9), goes.ToArray(), coes.ToArray()); //SubDefaultShape.BalanceBody(); //Sub//DefaultShape.CalcInertiaMultiplier(.1f); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; Vector2D[] noseconevertecies = new Vector2D[] { new Vector2D(10, 10), new Vector2D(0, 20), new Vector2D(-10, 25), new Vector2D(-10, -25), new Vector2D(0, -20), new Vector2D(10, -10), }; Vector2D[] mainhullvertecies = new Vector2D[] { new Vector2D(10, 25), new Vector2D(0, 40), new Vector2D(-10, 40), new Vector2D(-40, 20), new Vector2D(-40, -20), new Vector2D(-10, -40), new Vector2D(0, -40), new Vector2D(10, -25) }; IGeometry2D mainhull = new Polygon2D(ALVector2D.Zero, mainhullvertecies); IGeometry2D nosecone = new Polygon2D(new ALVector2D(0, new Vector2D(20.5f, 0)), noseconevertecies); DefaultShape = new RigidBodyTemplate(20, 654.58713987691476f, new IGeometry2D[] { mainhull, nosecone }, new Coefficients[] { DefaultCoefficients, DefaultCoefficients }); DefaultShape.BalanceBody(); //////DefaultShape.CalcInertiaMultiplier(.1f); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; Vector2D[] mainhullvertecies = new Vector2D[] { new Vector2D(60, 0), new Vector2D(40, 10), new Vector2D(0, 18), new Vector2D(-40, 13), new Vector2D(-40, -13), new Vector2D(0, -18), new Vector2D(40, -10) }; Vector2D[] mainhull2vertecies = new Vector2D[] { new Vector2D(30, 0), new Vector2D(20, 8), new Vector2D(10, 15), new Vector2D(-20, 20), new Vector2D(-20, -20), new Vector2D(10, -15), new Vector2D(20, -8) }; IGeometry2D mainhull = new Polygon2D(new ALVector2D(0, new Vector2D(-50, 0)), mainhullvertecies); IGeometry2D mainhull2 = new Polygon2D(ALVector2D.Zero, mainhull2vertecies); DefaultShape = new RigidBodyTemplate(14, 1026.1685677800115f, new IGeometry2D[] { mainhull2, mainhull, }, new Coefficients[] { DefaultCoefficients, DefaultCoefficients }); DefaultShape.BalanceBody(); ////DefaultShape.CalcInertiaMultiplier(.1f); }
public void Generate() { dynamic dialogSettings = new ExpandoObject(); dialogSettings.Title = "Generate input"; var viewModel = new InputGenerationViewModel(); bool?result = windowManager.ShowDialog(viewModel, settings: dialogSettings); if (result == true) { var coefficients = new Coefficients { E = viewModel.ElasticityCoefficient, Gamma = viewModel.GammaAngle, Nu = viewModel.PoissonCoefficient, P = viewModel.Pressure }; var config = Configuration.GenerateConfiguration(viewModel.InnerRadius, viewModel.OuterRadius, (int)viewModel.FiniteElementCount, coefficients); viewModel.Filename = viewModel.Filename ?? ("Input_" + DateTime.Now.ToShortDateString()); SimulatorWrapper.ConfigurationIo.GenerateInputFile(config, viewModel.Filename); PrepareSimulation(new ConfigurationArguments(viewModel.Filename, config)); } }
protected override void Open() { Coefficients coefficients = DemoHelper.Coefficients; DemoHelper.Coefficients.Restitution = 0; dispose += DemoHelper.CreateTank(DemoInfo, new Vector2D(50, 0)); dispose += DemoHelper.BasicDemoSetup(DemoInfo); Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan())); DemoHelper.AddFloor(DemoInfo, new ALVector2D(0, new Vector2D(700, 750))); IShape piston = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("piston.png"), 0, 16, 1); IShape socket = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("socket.png"), 0, 16, 1); DemoHelper.AddShape(DemoInfo, piston, 10, new ALVector2D(0, 300, 300)); DemoHelper.AddShape(DemoInfo, socket, 10, new ALVector2D(0, 300, 300)); IShape fighter = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("fighter.png"), 3, 16, 3); DemoHelper.AddShape(DemoInfo, fighter, 50, new ALVector2D(0, 500, 300)); DemoHelper.AddShape(DemoInfo, fighter, 50, new ALVector2D(0, 500, 100)); IShape starfury = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("Starfury.png"), 3, 16, 3); DemoHelper.AddShape(DemoInfo, starfury, 50, new ALVector2D(0, 700, 300)); DemoHelper.AddShape(DemoInfo, starfury, 50, new ALVector2D(0, 700, 100)); Body ball = DemoHelper.AddCircle(DemoInfo, 80, 20, 4000, new ALVector2D(0, 1028, 272));// //AddShape(new CircleShape(80, 20), 4000, new ALVector2D(0, new Vector2D(1028, 272))); DemoHelper.Coefficients = coefficients; }
public T Multiply(T other) { // Create an extended list which can contain results from both coefficient collections. List <BigInteger> b = new List <BigInteger>(new BigInteger[(Degree * 2) - 1]); // Compute each product linearly for every index in our list. for (int i = 0; i < Coefficients.Count; i++) { for (int j = 0; j < other.Coefficients.Count; j++) { b[i + j] += Coefficients.ElementAt(i) * other.Coefficients.ElementAt(j); } } for (int exp = Degree - 2; exp >= 0; exp--) { BigInteger top = b[b.Count - 1]; b.RemoveAt(b.Count - 1); for (int i = 0; i < ModulusCoefficients.Count; i++) { b[exp + i] -= top * ModulusCoefficients.ElementAt(i); } } // Perform modular division to wrap our coefficients around p. return(New(b.Select(x => x.Mod(Bn128Curve.P)))); }
protected override void Open() { Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan())); IShape bombShape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("rocket.png"), 2, 16, 3); dispose += DemoHelper.BasicDemoSetup(DemoInfo); Coefficients o = DemoHelper.Coefficients; DemoHelper.Coefficients = new Coefficients(1, .5f); DemoHelper.AddFloor(DemoInfo, new ALVector2D(0, new Vector2D(700, 750))); Body b1 = DemoHelper.AddRectangle(DemoInfo, 750, 100, Scalar.PositiveInfinity, new ALVector2D(0, 0, 750 / 2)); b1.IgnoresGravity = true; Body b2 = DemoHelper.AddRectangle(DemoInfo, 750, 100, Scalar.PositiveInfinity, new ALVector2D(0, 1024, 750 / 2)); b2.IgnoresGravity = true; DemoHelper.Coefficients = new Coefficients(.7f, .05f); for (int x = 60; x < 80; x += 10) { for (int y = -2000; y < 700; y += 12) { Body g = DemoHelper.AddCircle(DemoInfo, 5, 7, 3, new ALVector2D(0, x, y)); g.State.Velocity.Angular = 1; // g.State.Velocity.Linear = new Vector2D(0, 500); } } DemoHelper.Coefficients = o; }
public World() { float w, h; w = 640.0f; h = 480.0f; bodyList = new List <Body>(); engine = new PhysicsEngine(); engine.BroadPhase = new Physics2DDotNet.Detectors.BruteForceDetector(); engine.Solver = new Physics2DDotNet.Solvers.SequentialImpulsesSolver(); engine.AddLogic(new GravityField(new Vector2D(0, 500), new Lifespan())); Coefficients coffecients = new Coefficients(.8f, .5f); Shape floor = new Polygon(Polygon.CreateRectangle(100.0f, w), 2.0f); Shape left = new Polygon(Polygon.CreateRectangle(h, 100.0f), 2.0f); Shape right = new Polygon(Polygon.CreateRectangle(h, 100.0f), 2.0f); Physics2DDotNet.Body floorData = new Physics2DDotNet.Body(new PhysicsState(new ALVector2D(0.0f, w / 2.0f, h + 50.0f)), floor, new MassInfo(Scalar.PositiveInfinity, Scalar.PositiveInfinity), coffecients, new Lifespan()); Physics2DDotNet.Body leftData = new Physics2DDotNet.Body(new PhysicsState(new ALVector2D(0.0f, -50.0f, h / 2.0f)), left, new MassInfo(Scalar.PositiveInfinity, Scalar.PositiveInfinity), coffecients, new Lifespan()); Physics2DDotNet.Body rightData = new Physics2DDotNet.Body(new PhysicsState(new ALVector2D(0.0f, w + 50.0f, h / 2.0f)), right, new MassInfo(Scalar.PositiveInfinity, Scalar.PositiveInfinity), coffecients, new Lifespan()); floorData.IgnoresGravity = true; leftData.IgnoresGravity = true; rightData.IgnoresGravity = true; engine.AddBody(floorData); engine.AddBody(leftData); engine.AddBody(rightData); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; List <IGeometry2D> goes = new List <IGeometry2D>(); List <Coefficients> coes = new List <Coefficients>(); Vector2D[] pods = Polygon2D.FromRectangle(2, 5); Vector2D[] mainhullp = Polygon2D.FromRectangle(3, 7); Vector2D[] subhullp = Polygon2D.FromRectangle(4, 2); goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI + .7f, new Vector2D(-3, 2)), subhullp)); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI - .7f, new Vector2D(-3, -2)), subhullp)); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(-3, 3)), pods)); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(-3, -3)), pods)); coes.Add(DefaultCoefficients); goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(0, 0)), mainhullp)); coes.Add(DefaultCoefficients); DefaultShape = new RigidBodyTemplate(.01f, 9.609863f, goes.ToArray(), coes.ToArray()); DefaultShape.BalanceBody(); DefaultShape.CalcInertiaMultiplier(.1f); }
static void InitShape() { Coefficients DefaultCoefficients = TimeWarp.Coefficients; DefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(.01f, 90), new IGeometry2D[] { new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(10, 20)) }, new Coefficients[] { DefaultCoefficients }); //DefaultShape.BalanceBody(); //////DefaultShape.CalcInertiaMultiplier(.1f); }
public bool IsSolution(IEnumerable <double> x) { if (x.Count() != Coefficients.Count) { throw new ArgumentException("x must have the same length as coefficients."); } return(Coefficients.Zip(x, (a, var) => (a, var)).Sum(c => c.a * c.var) == B); }
public WilksCoefficient(double total, double weight, bool isMale) { Coefficients coefficients = new Coefficients(isMale); double x = weight; wilksScore = total * 500 / (coefficients.a + coefficients.b * x + coefficients.c * Math.Pow(x, 2) + coefficients.d * Math.Pow(x, 3) + coefficients.e * Math.Pow(x, 4) + coefficients.f * Math.Pow(x, 5)); }
public void TestCoefficientInitMale() { double expected_male_a = -216.0475144; var maleCoefficients = new Coefficients(true); double actual_male_a = maleCoefficients.a; Assert.AreEqual(expected_male_a, actual_male_a); }
public void TestCoefficientInitFemale() { double expected_female_a = 594.31747775582; var femaleCoefficients = new Coefficients(false); double actual_female_a = femaleCoefficients.a; Assert.AreEqual(expected_female_a, actual_female_a); }