public Cubic[] calcNaturalCubic(int n, float[] x) { float[] gamma = new float[n + 1]; float[] delta = new float[n + 1]; float[] D = new float[n + 1]; int i; gamma[0] = 1.0f / 2.0f; for (i = 1; i < n; i++) { gamma[i] = 1 / (4 - gamma[i - 1]); } gamma[n] = 1 / (2 - gamma[n - 1]); delta[0] = 3 * (x[1] - x[0]) * gamma[0]; for (i = 1; i < n; i++) { delta[i] = (3 * (x[i + 1] - x[i - 1]) - delta[i - 1]) * gamma[i]; } delta[n] = (3 * (x[n] - x[n - 1]) - delta[n - 1]) * gamma[n]; D[n] = delta[n]; for (i = n - 1; i >= 0; i--) { D[i] = delta[i] - gamma[i] * D[i + 1]; } Cubic[] C = new Cubic[n + 1]; for (i = 0; i < n; i++) { C[i] = new Cubic((float)x[i], D[i], 3 * (x[i + 1] - x[i]) - 2 * D[i] - D[i + 1], 2 * (x[i] - x[i + 1]) + D[i] + D[i + 1]); } return(C); }
public static Func <float, float> GetEaseFunction(EaseFunction functionType, EaseType easeType) { switch (functionType) { case EaseFunction.Linear: return(Linear); case EaseFunction.Quad: return(Quad.Get(easeType)); case EaseFunction.Cubic: return(Cubic.Get(easeType)); case EaseFunction.Quartic: return(Quartic.Get(easeType)); case EaseFunction.Quintic: return(Quintic.Get(easeType)); case EaseFunction.Sin: return(Sin.Get(easeType)); case EaseFunction.Exponential: return(Exponential.Get(easeType)); case EaseFunction.Circular: return(Circular.Get(easeType)); case EaseFunction.Bounce: return(Bounce.Get(easeType)); case EaseFunction.Elastic: return(Elastic.Get(easeType)); case EaseFunction.Back: return(Back.Get(easeType)); } return(f => f); }
// Use this for initialization void Start() { if (this.Controller == null) { this.Controller = GameObject.FindObjectOfType <ElectromagneticFieldControllerScript> (); } FieldValues = new VolumeBuffer <Vector3> (Cubic <int> .CreateSame(CubeSize)); if (this.UseDebugMesh) { var mf = this.GetComponent <MeshFilter> (); if (mf == null) { this.UseDebugMesh = false; Debug.Assert(mf != null, "Please setup a MeshFilter and MeshRenderer on this object"); } SurfaceMesh = new Mesh(); MeshVertices = new Vector3[FieldValues.Length * 3]; MeshNormals = new Vector3[FieldValues.Length * 3]; mf.mesh = SurfaceMesh; } }
/// <summary> /// Convert cubic coordinate to offset /// </summary> public Offset ToOffset(Cubic coord) { switch (Type) { case HexagonalGridType.PointyOdd: { var col = coord.X + (coord.Z - (coord.Z & 1)) / 2; var row = coord.Z; return(new Offset(col, row)); } case HexagonalGridType.PointyEven: { var col = coord.X + (coord.Z + (coord.Z & 1)) / 2; var row = coord.Z; return(new Offset(col, row)); } case HexagonalGridType.FlatOdd: { var col = coord.X; var row = coord.Z + (coord.X - (coord.X & 1)) / 2; return(new Offset(col, row)); } case HexagonalGridType.FlatEven: { var col = coord.X; var row = coord.Z + (coord.X + (coord.X & 1)) / 2; return(new Offset(col, row)); } default: throw new HexagonalException($"{nameof(ToOffset)} failed with unexpected {nameof(Type)}", this, (nameof(coord), coord)); } }
static void Main() { int num = Cubic.ReadNum(); System.Console.WriteLine(CalcCubic(num)); }
public CubicZeroCurve(DateVector dates, DoubleVector yields, DayCounter dayCounter, Calendar calendar, Cubic i, Compounding compounding, Frequency frequency) : this(NQuantLibcPINVOKE.new_CubicZeroCurve__SWIG_0(DateVector.getCPtr(dates), DoubleVector.getCPtr(yields), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar), Cubic.getCPtr(i), (int)compounding, (int)frequency), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public CubicInterpolatedSmileSection(double expiryTime, DoubleVector strikes, QuoteHandleVector stdDevHandles, QuoteHandle atmLevel, Cubic interpolator) : this(NQuantLibcPINVOKE.new_CubicInterpolatedSmileSection__SWIG_3(expiryTime, DoubleVector.getCPtr(strikes), QuoteHandleVector.getCPtr(stdDevHandles), QuoteHandle.getCPtr(atmLevel), Cubic.getCPtr(interpolator)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Cubic obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
// Constructor public HexTile(Cubic _cubeCoord) { CubicCoords = _cubeCoord; }
public CubicInterpolatedSmileSection(Date d, DoubleVector strikes, DoubleVector stdDevs, double atmLevel, DayCounter dc, Cubic interpolator, Date referenceDate) : this(NQuantLibcPINVOKE.new_CubicInterpolatedSmileSection__SWIG_18(Date.getCPtr(d), DoubleVector.getCPtr(strikes), DoubleVector.getCPtr(stdDevs), atmLevel, DayCounter.getCPtr(dc), Cubic.getCPtr(interpolator), Date.getCPtr(referenceDate)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
/// <summary> /// Convert hex based on its cubic coordinate to it center position in 3d space OZ /// </summary> public Vector3 ToVector3(Cubic coord, float y = 0) { return(ToPoint2(coord).AsVector3(y)); }
public void EnsureSetup() { if (isSetup) { return; } isSetup = true; FieldOverallAlpha = 1.0f; ParticleFlowRate = 1.0f; if (!this.Body) { this.Body = this.gameObject.GetComponentInParent <BodyLandmarks> (); } if (!this.Body) { if (!this.Hand) { this.Hand = this.gameObject.GetComponentInParent <MainEnergyApp> (); } this.ChiBall = this.gameObject.GetComponentInParent <ChiHandEnergyBall> (); } Debug.Assert((this.Body) || (this.Hand) || (this.ChiBall)); if (!this.ExcersizeSystem) { this.ExcersizeSystem = GameObject.FindObjectOfType <ExcersizeSharedScheduler> (); } bool isMobile = (Application.platform == UnityEngine.RuntimePlatform.IPhonePlayer); int sideRes = (isMobile ? this.VoxelSideResMobile : this.VoxelSideRes); // 8; if (this.Body) { this.Body.EnsureSetup(); int chakraToShow = CurrentFocusChakra; //3; this.FieldsCells = new VolumeBuffer <DynFieldCell> (Cubic <int> .CreateSame(sideRes)); var scl = OneOver(this.FieldsCells.Header.Size.AsVector3()); var l2w = this.transform.localToWorldMatrix; var cntr = Body.Chakras.AllChakras [chakraToShow].transform.position; // l2w.MultiplyPoint (Vector3.zero); foreach (var nd in this.FieldsCells.AllIndices3()) { var cell = this.FieldsCells.Read(nd.AsCubic()); cell.Pos = this.transform.localToWorldMatrix.MultiplyPoint(FieldsCells.Header.CubicToDecimalUnit(nd) - (Vector3.one * 0.5f)); if (!(SkipRandomPlacement)) { cell.Pos += Scale(Random.insideUnitSphere, scl); // add random offset } cell.Direction = cntr - cell.Pos; cell.LatestColor = Color.white; cell.Twist = 0.0f; cell.VoxelIndex = nd; this.FieldsCells.Write(nd.AsCubic(), cell); } } else if (this.Hand) { var arrows = this.Hand.FindAllFlowNodes(); var n = arrows.Count; this.IsStaticLayout = true; this.FieldsCells = new VolumeBuffer <DynFieldCell> (Cubic <int> .Create(n, 1, 1)); for (int i = 0; i < n; i++) { var cell = this.FieldsCells.Array [i]; var arrow = arrows [i]; cell.Pos = arrow.transform.position; cell.Direction = arrow.transform.up * 50.0f; cell.LatestColor = Color.green; cell.Twist = 0.0f; cell.VoxelIndex = new Int3(i, 0, 0); this.FieldsCells.Array [i] = cell; } } else if (this.ChiBall) { this.FieldsCells = new VolumeBuffer <DynFieldCell> (Cubic <int> .CreateSame(sideRes)); var scl = OneOver(this.FieldsCells.Header.Size.AsVector3()); var cntr = this.ChiBall.transform.position; var l2w = this.transform.localToWorldMatrix; foreach (var nd in this.FieldsCells.AllIndices3()) { var cell = this.FieldsCells.Read(nd.AsCubic()); cell.Pos = this.transform.localToWorldMatrix.MultiplyPoint(FieldsCells.Header.CubicToDecimalUnit(nd) - (Vector3.one * 0.5f)); if (!(SkipRandomPlacement)) { cell.Pos += Scale(Random.insideUnitSphere, scl); // add random offset } cell.Direction = cntr - cell.Pos; cell.LatestColor = Color.white; cell.Twist = 0.0f; cell.VoxelIndex = nd; this.FieldsCells.Write(nd.AsCubic(), cell); } } this.UpdateCellFieldDir(snapToCurrent: true); }
public CubicZeroCurve(DateVector dates, DoubleVector yields, DayCounter dayCounter, Calendar calendar, Cubic i) : this(NQuantLibcPINVOKE.new_CubicZeroCurve__SWIG_2(DateVector.getCPtr(dates), DoubleVector.getCPtr(yields), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar), Cubic.getCPtr(i)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public void proceed(rate_functions Rate_function, bool invert, bool mobility, bool Cal_control) { Constant constant = new Constant(); Linear linear = new Linear(); Quadratic quadratic = new Quadratic(); Cubic cubic = new Cubic(); Exponencional exponencional = new Exponencional(); Exponencional2 exponencional2 = new Exponencional2(); Exponencional3 exponencional3 = new Exponencional3(); Exponencional4 exponencional4 = new Exponencional4(); Exponencional5 exponencional5 = new Exponencional5(); Association acoss = new Association(); if (mobility) // functions for a mobility { comboBox1.Items.Add(constant); comboBox1.Items.Add(linear); comboBox1.Items.Add(quadratic); comboBox1.Items.Add(cubic); comboBox1.Items.Add(exponencional); comboBox1.Items.Add(exponencional3); comboBox1.Items.Add(exponencional4); comboBox1.Items.Add(exponencional5); } else // functions for a rate konstant { comboBox1.Items.Add(constant); comboBox1.Items.Add(exponencional2); comboBox1.Items.Add(exponencional3); comboBox1.Items.Add(acoss); } if (Rate_function != null) { if (Rate_function.ToString() == constant.ToString()) { comboBox1.Items.Remove(constant); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = false; checkBox3.Enabled = false; textBox4.Enabled = false; checkBox4.Enabled = false; textBox5.Enabled = false; checkBox5.Enabled = false; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; } if (Rate_function.ToString() == linear.ToString()) { comboBox1.Items.Remove(linear); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = false; checkBox4.Enabled = false; textBox5.Enabled = false; checkBox5.Enabled = false; textBox4.Text = ""; textBox5.Text = ""; } if (Rate_function.ToString() == quadratic.ToString()) { comboBox1.Items.Remove(quadratic); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox4.Text = Rate_function.C.ToString(); checkBox4.Checked = Rate_function.C_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = true; checkBox4.Enabled = true; textBox5.Enabled = false; checkBox5.Enabled = false; textBox5.Text = ""; } if (Rate_function.ToString() == cubic.ToString()) { comboBox1.Items.Remove(cubic); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox4.Text = Rate_function.C.ToString(); checkBox4.Checked = Rate_function.C_lock; textBox5.Text = Rate_function.D.ToString(); checkBox5.Checked = Rate_function.D_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = true; checkBox4.Enabled = true; textBox5.Enabled = true; checkBox5.Enabled = true; } if (Rate_function.ToString() == exponencional.ToString()) { comboBox1.Items.Remove(exponencional); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = false; checkBox4.Enabled = false; textBox5.Enabled = false; checkBox5.Enabled = false; textBox4.Text = ""; textBox5.Text = ""; } if (Rate_function.ToString() == exponencional2.ToString()) { comboBox1.Items.Remove(exponencional2); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = false; checkBox4.Enabled = false; textBox5.Enabled = false; checkBox5.Enabled = false; textBox4.Text = ""; textBox5.Text = ""; } if (Rate_function.ToString() == exponencional3.ToString()) { comboBox1.Items.Remove(exponencional3); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox4.Text = Rate_function.C.ToString(); checkBox4.Checked = Rate_function.C_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = true; checkBox4.Enabled = true; textBox5.Enabled = false; checkBox5.Enabled = false; textBox4.Text = ""; textBox5.Text = ""; } if (Rate_function.ToString() == exponencional4.ToString()) { comboBox1.Items.Remove(exponencional4); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = false; checkBox4.Enabled = false; textBox5.Enabled = false; checkBox5.Enabled = false; textBox4.Text = ""; textBox5.Text = ""; } if (Rate_function.ToString() == exponencional5.ToString()) { comboBox1.Items.Remove(exponencional5); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = false; checkBox4.Enabled = false; textBox5.Enabled = false; checkBox5.Enabled = false; textBox4.Text = ""; textBox5.Text = ""; } if (Rate_function.ToString() == acoss.ToString()) { comboBox1.Items.Remove(acoss); comboBox1.Items.Add(Rate_function); textBox2.Text = Rate_function.A.ToString(); checkBox2.Checked = Rate_function.A_lock; textBox3.Text = Rate_function.B.ToString(); checkBox3.Checked = Rate_function.B_lock; textBox2.Enabled = true; checkBox2.Enabled = true; textBox3.Enabled = true; checkBox3.Enabled = true; textBox4.Enabled = false; checkBox4.Enabled = false; textBox5.Enabled = false; checkBox5.Enabled = false; textBox4.Text = ""; textBox5.Text = ""; } comboBox1.SelectedItem = Rate_function; comboBox1.Text = Rate_function.ToString(); } _invert = invert; _mobility = mobility; _cal_control = Cal_control; }
public static float GetTerpedPosition(float time, float totalTime, Function function, Direction direction) { switch (function) { case Function.Quadratic: switch (direction) { case Direction.In: return(Quadratic.In(time / totalTime)); case Direction.Out: return(Quadratic.Out(time / totalTime)); default: return(Quadratic.InOut(time / totalTime)); } case Function.Cubic: switch (direction) { case Direction.In: return(Cubic.In(time / totalTime)); case Direction.Out: return(Cubic.Out(time / totalTime)); default: return(Cubic.InOut(time / totalTime)); } case Function.Quartic: switch (direction) { case Direction.In: return(Quartic.In(time / totalTime)); case Direction.Out: return(Quartic.Out(time / totalTime)); default: return(Quartic.InOut(time / totalTime)); } case Function.Quintic: switch (direction) { case Direction.In: return(Quintic.In(time / totalTime)); case Direction.Out: return(Quintic.Out(time / totalTime)); default: return(Quintic.InOut(time / totalTime)); } case Function.Sinusoidal: switch (direction) { case Direction.In: return(Sinusoidal.In(time / totalTime)); case Direction.Out: return(Sinusoidal.Out(time / totalTime)); default: return(Sinusoidal.InOut(time / totalTime)); } case Function.Exponential: switch (direction) { case Direction.In: return(Exponential.In(time / totalTime)); case Direction.Out: return(Exponential.Out(time / totalTime)); default: return(Exponential.InOut(time / totalTime)); } case Function.Circular: switch (direction) { case Direction.In: return(Circular.In(time / totalTime)); case Direction.Out: return(Circular.Out(time / totalTime)); default: return(Circular.InOut(time / totalTime)); } case Function.Elastic: switch (direction) { case Direction.In: return(Elastic.In(time / totalTime)); case Direction.Out: return(Elastic.Out(time / totalTime)); default: return(Elastic.InOut(time / totalTime)); } case Function.Back: switch (direction) { case Direction.In: return(Back.In(time / totalTime)); case Direction.Out: return(Back.Out(time / totalTime)); default: return(Back.InOut(time / totalTime)); } default: //Function.Bounce: switch (direction) { case Direction.In: return(Bounce.In(time / totalTime)); case Direction.Out: return(Bounce.Out(time / totalTime)); default: return(Bounce.InOut(time / totalTime)); } } }
public void GoNorthWhenThereIsNoNorth() { Cubic origin = new Cubic(0, 0, 0, Orientation.CORNER_TOP, Scew.even); origin.GetNeighbor(Direction.NORTH); }
public Cubic[] calcNaturalCubic(int n, float[] x) { float[] gamma = new float[n+1]; float[] delta = new float[n+1]; float[] D = new float[n+1]; int i; gamma[0] = 1.0f/2.0f; for ( i = 1; i < n; i++) { gamma[i] = 1/(4-gamma[i-1]); } gamma[n] = 1/(2-gamma[n-1]); delta[0] = 3*(x[1]-x[0])*gamma[0]; for ( i = 1; i < n; i++) { delta[i] = (3*(x[i+1]-x[i-1])-delta[i-1])*gamma[i]; } delta[n] = (3*(x[n]-x[n-1])-delta[n-1])*gamma[n]; D[n] = delta[n]; for ( i = n-1; i >= 0; i--) { D[i] = delta[i] - gamma[i]*D[i+1]; } Cubic[] C = new Cubic[n+1]; for ( i = 0; i < n; i++) { C[i] = new Cubic((float)x[i], D[i], 3*(x[i+1] - x[i]) - 2*D[i] - D[i+1], 2*(x[i] - x[i+1]) + D[i] + D[i+1]); } return C; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Cubic obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public PiecewiseCubicZero(int settlementDays, Calendar calendar, RateHelperVector instruments, DayCounter dayCounter, QuoteHandleVector jumps, DateVector jumpDates, double accuracy, Cubic i) : this(NQuantLibcPINVOKE.new_PiecewiseCubicZero__SWIG_5(settlementDays, Calendar.getCPtr(calendar), RateHelperVector.getCPtr(instruments), DayCounter.getCPtr(dayCounter), QuoteHandleVector.getCPtr(jumps), DateVector.getCPtr(jumpDates), accuracy, Cubic.getCPtr(i)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
private void button1_Click(object sender, EventArgs e) { try { if (comboBox1.SelectedItem.ToString() == "A") { Constant new_constant = new Constant(Convertor(textBox2.Text), checkBox2.Checked); if (!_cal_control) { Main.new_rate_function = new_constant; } else { Resources.item_mobility = new_constant; } } if (comboBox1.SelectedItem.ToString() == "A + B*(E/N)") { Linear new_linear = new Linear(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); if (!_cal_control) { Main.new_rate_function = new_linear; } else { Resources.item_mobility = new_linear; } } if (comboBox1.SelectedItem.ToString() == "A + B*(E/N) + C*(E/N)^2") { Quadratic new_quadratic = new Quadratic(Convertor(textBox2.Text), Convertor(textBox3.Text), Convertor(textBox4.Text), checkBox2.Checked, checkBox3.Checked, checkBox4.Checked); if (!_cal_control) { Main.new_rate_function = new_quadratic; } else { Resources.item_mobility = new_quadratic; } } if (comboBox1.SelectedItem.ToString() == "A + B*(E/N) + C*(E/N)^2 + D*(E/N)^3") { Cubic new_cubic = new Cubic(Convertor(textBox2.Text), Convertor(textBox3.Text), Convertor(textBox4.Text), Convertor(textBox5.Text), checkBox2.Checked, checkBox3.Checked, checkBox4.Checked, checkBox5.Checked); if (!_cal_control) { Main.new_rate_function = new_cubic; } else { Resources.item_mobility = new_cubic; } } if (comboBox1.SelectedItem.ToString() == "A*EXP(B*(E/N))") { Exponencional new_exponencional = new Exponencional(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); if (!_cal_control) { Main.new_rate_function = new_exponencional; } else { Resources.item_mobility = new_exponencional; } } if (comboBox1.SelectedItem.ToString() == "A*EXP(B/Er(E/N))") { Exponencional2 new_exponencional2 = new Exponencional2(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); if (!_cal_control) { Main.new_rate_function = new_exponencional2; } else { Resources.item_mobility = new_exponencional2; } } if (comboBox1.SelectedItem.ToString() == "C + A*EXP(B/(E/N))") //Modify to A*EXP(B/C + E) { Exponencional3 new_exponencional3 = new Exponencional3(Convertor(textBox2.Text), Convertor(textBox3.Text), Convertor(textBox4.Text), checkBox2.Checked, checkBox3.Checked, checkBox4.Checked); if (!_cal_control) { Main.new_rate_function = new_exponencional3; } else { Resources.item_mobility = new_exponencional3; } } if (comboBox1.SelectedItem.ToString() == "A/(1+(E/N))^B") { Exponencional4 new_exponencional4 = new Exponencional4(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); if (!_cal_control) { Main.new_rate_function = new_exponencional4; } else { Resources.item_mobility = new_exponencional4; } } if (comboBox1.SelectedItem.ToString() == "A*EXP(B*(E/N)^2)") { Exponencional5 new_exponencional = new Exponencional5(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); if (!_cal_control) { Main.new_rate_function = new_exponencional; } else { Resources.item_mobility = new_exponencional; } } if (comboBox1.SelectedItem.ToString() == "A/Er(E/N)^B") { Association new_acoss = new Association(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); Main.new_rate_function = new_acoss; if (!_cal_control) { Main.new_rate_function = new_acoss; } else { Resources.item_mobility = new_acoss; } } if (!_mobility) { if (_invert) { Main.use_new_rate_(); } else { Main.use_new_rate(); } } else { if (!_cal_control) { Main.use_new_mobility(); } else { Resources.use_new_mobility(); } } this.Dispose(); } catch { MessageBox.Show("Unable to use selected function."); } }
public List <HexTile> BuildHexagonalBoard() { // Ensure there is a HexTile if (!objTile) { Debug.Log("Unable to create board. No HexTile prefab selected."); return(null); } // Board Array List <HexTile> gameBoard = new List <HexTile>(); // Movement Vectors Vector3 DownRight = new Vector3(dx, 0f, -dz); Vector3 DownDown = new Vector3(0f, 0f, -2 * dz); Vector3 DownLeft = new Vector3(-dx, 0f, -dz); Vector3 UpLeft = new Vector3(-dx, 0f, +dz); Vector3 UpUp = new Vector3(0f, 0f, 2 * dz); Vector3 UpRight = new Vector3(dx, 0f, dz); // Set inital spawn location to HexTile. Vector3 SpawnLocation = Vector3.zero; Cubic SpawnCoord = new Cubic(0, 0, 0); int TileID = 0; // Spawn initial HexTile in board center HexTile centerTile = SpawnTile(SpawnLocation, SpawnCoord, TileID); gameBoard.Add(centerTile); // Loop through each layer of HexTiles for (int r = 1; r <= hexRadius; r++) { // Top HexTile as start position SpawnLocation += UpUp; SpawnCoord.Cube_Add(Cubic.N); // Top Right for (int i = 1; i <= r; i++) { SpawnLocation += DownRight; SpawnCoord.Cube_Add(Cubic.SE); HexTile tempTile = SpawnTile(SpawnLocation, SpawnCoord, ++TileID); gameBoard.Add(tempTile); } // Right for (int i = 1; i <= r; i++) { SpawnLocation += DownDown; SpawnCoord.Cube_Add(Cubic.S); HexTile tempTile = SpawnTile(SpawnLocation, SpawnCoord, ++TileID); gameBoard.Add(tempTile); } // Bottom Right for (int i = 1; i <= r; i++) { SpawnLocation += DownLeft; SpawnCoord.Cube_Add(Cubic.SW); HexTile tempTile = SpawnTile(SpawnLocation, SpawnCoord, ++TileID); gameBoard.Add(tempTile); } // Bottom Left for (int i = 1; i <= r; i++) { SpawnLocation += UpLeft; SpawnCoord.Cube_Add(Cubic.NW); HexTile tempTile = SpawnTile(SpawnLocation, SpawnCoord, ++TileID); gameBoard.Add(tempTile); } // Left for (int i = 1; i <= r; i++) { SpawnLocation += UpUp; SpawnCoord.Cube_Add(Cubic.N); HexTile tempTile = SpawnTile(SpawnLocation, SpawnCoord, ++TileID); gameBoard.Add(tempTile); } // Top Right for (int i = 1; i <= r; i++) { SpawnLocation += UpRight; SpawnCoord.Cube_Add(Cubic.NE); HexTile tempTile = SpawnTile(SpawnLocation, SpawnCoord, ++TileID); gameBoard.Add(tempTile); } } return(gameBoard); }
private void Draw() { try { string title = "k (cm^3/s or cm^6/s)"; if (_mobility) { title = "K0(cm ^ 2 / Vs)"; } PlotModel model = new PlotModel() { LegendSymbolLength = 24, IsLegendVisible = false }; model.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "E (E/N)", MajorGridlineStyle = LineStyle.Dash }); model.Axes.Add(new LogarithmicAxis() { Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 100, Title = title }); LineSeries fs = new LineSeries(); if (comboBox1.SelectedItem.ToString() == "A") { Constant new_constant = new Constant(Convertor(textBox2.Text), checkBox2.Checked); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_constant.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "A + B*(E/N)") { Linear new_linear = new Linear(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_linear.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "A + B*(E/N) + C*(E/N)^2") { Quadratic new_quadratic = new Quadratic(Convertor(textBox2.Text), Convertor(textBox3.Text), Convertor(textBox4.Text), checkBox2.Checked, checkBox3.Checked, checkBox4.Checked); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_quadratic.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "A + B*(E/N) + C*(E/N)^2 + D*(E/N)^3") { Cubic new_cubic = new Cubic(Convertor(textBox2.Text), Convertor(textBox3.Text), Convertor(textBox4.Text), Convertor(textBox5.Text), checkBox2.Checked, checkBox3.Checked, checkBox4.Checked, checkBox5.Checked); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_cubic.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "A*EXP(B*(E/N))") { Exponencional new_exponencional = new Exponencional(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_exponencional.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "A*EXP(B/Er(E/N))") { Exponencional2 new_exponencional2 = new Exponencional2(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); new_exponencional2.reactant_mobility = new Constant(10, true); new_exponencional2.mass_element = 16 * 1.66053904e-27; model.Axes.Clear(); model.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "E (V/cm)", MajorGridlineStyle = LineStyle.Dash }); model.Axes.Add(new LogarithmicAxis() { Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 100, Title = "k for mass element 16u" }); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_exponencional2.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "C + A*EXP(B/(E/N))") { Exponencional3 new_exponencional3 = new Exponencional3(Convertor(textBox2.Text), Convertor(textBox3.Text), Convertor(textBox4.Text), checkBox2.Checked, checkBox3.Checked, checkBox4.Checked); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_exponencional3.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "A/(1+(E/N))^B") { Exponencional4 new_exponencional4 = new Exponencional4(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_exponencional4.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "A*EXP(B*(E/N)^2)") { Exponencional5 new_exponencional = new Exponencional5(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_exponencional.Value(i))); } model.Series.Add(fs); plot1.Model = model; } if (comboBox1.SelectedItem.ToString() == "A/Er(E/N)^B") { Association new_acoss = new Association(Convertor(textBox2.Text), Convertor(textBox3.Text), checkBox2.Checked, checkBox3.Checked); new_acoss.reactant_mobility = new Constant(10, true); new_acoss.mass_element = 16 * 1.66053904e-27; model.Axes.Clear(); model.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "E (V/cm)", MajorGridlineStyle = LineStyle.Dash }); model.Axes.Add(new LogarithmicAxis() { Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 100, Title = "k for mass element 16u" }); for (int i = 0; i < 100; i++) { fs.Points.Add(new DataPoint(i, new_acoss.Value(i))); } model.Series.Add(fs); plot1.Model = model; } } catch { } }
public PiecewiseCubicZero(int settlementDays, Calendar calendar, RateHelperVector instruments, DayCounter dayCounter, QuoteHandleVector jumps, DateVector jumpDates, double accuracy, Cubic i) : this(NQuantLibcPINVOKE.new_PiecewiseCubicZero__SWIG_5(settlementDays, Calendar.getCPtr(calendar), RateHelperVector.getCPtr(instruments), DayCounter.getCPtr(dayCounter), QuoteHandleVector.getCPtr(jumps), DateVector.getCPtr(jumpDates), accuracy, Cubic.getCPtr(i)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
/// <summary> /// Convert hex based on its cubic coordinate to it center position in 2d space /// </summary> public Vector2 ToVector2(Cubic coord) { return(ToPoint2(coord).AsVector2()); }
public bool IsSafe(Cubic <int> pos) { return(pos.Select2(this.Size, (i, sz) => ((i >= 0) && (i < sz))).AllTrue()); }
private void Awake() { mesh = GetComponentInChildren <MeshRenderer>(); CubicCoords = new Cubic(0, 0, 0); matDefault = mesh.material; }
public bool IsEdge(Cubic <int> pos) { return(pos.Select2(this.Size, (i, sz) => ((i == 0) || ((i + 1) == sz))).AnyTrue()); }
public CubicInterpolatedSmileSection(Date d, DoubleVector strikes, QuoteHandleVector stdDevHandles, QuoteHandle atmLevel, DayCounter dc, Cubic interpolator) : this(NQuantLibcPINVOKE.new_CubicInterpolatedSmileSection__SWIG_13(Date.getCPtr(d), DoubleVector.getCPtr(strikes), QuoteHandleVector.getCPtr(stdDevHandles), QuoteHandle.getCPtr(atmLevel), DayCounter.getCPtr(dc), Cubic.getCPtr(interpolator)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public T Read(Cubic <int> pos) { return(this.Read(new Int3(pos))); }
public CubicInterpolatedSmileSection(double expiryTime, DoubleVector strikes, QuoteHandleVector stdDevHandles, QuoteHandle atmLevel, Cubic interpolator, DayCounter dc, VolatilityType type, double shift) : this(NQuantLibcPINVOKE.new_CubicInterpolatedSmileSection__SWIG_0(expiryTime, DoubleVector.getCPtr(strikes), QuoteHandleVector.getCPtr(stdDevHandles), QuoteHandle.getCPtr(atmLevel), Cubic.getCPtr(interpolator), DayCounter.getCPtr(dc), (int)type, shift), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public void Write(Cubic <int> pos, T val) { this.Write(new Int3(pos), val); }
public CubicInterpolatedSmileSection(double expiryTime, DoubleVector strikes, DoubleVector stdDevs, double atmLevel, Cubic interpolator, DayCounter dc) : this(NQuantLibcPINVOKE.new_CubicInterpolatedSmileSection__SWIG_7(expiryTime, DoubleVector.getCPtr(strikes), DoubleVector.getCPtr(stdDevs), atmLevel, Cubic.getCPtr(interpolator), DayCounter.getCPtr(dc)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
//------------------------------------------------------------------------------------------------------------ public static float GetEasingFunction(Type easingFunction, float t) { // Quad if (easingFunction == Type.EaseInQuad) { return(Quadratic.In(t)); } if (easingFunction == Type.EaseOutQuad) { return(Quadratic.Out(t)); } if (easingFunction == Type.EaseInOutQuad) { return(Quadratic.InOut(t)); } // Cubic if (easingFunction == Type.EaseInCubic) { return(Cubic.In(t)); } if (easingFunction == Type.EaseOutCubic) { return(Cubic.Out(t)); } if (easingFunction == Type.EaseInOutCubic) { return(Cubic.InOut(t)); } // Quart if (easingFunction == Type.EaseInQuart) { return(Quartic.In(t)); } if (easingFunction == Type.EaseOutQuart) { return(Quartic.Out(t));; } if (easingFunction == Type.EaseInOutQuart) { return(Quartic.InOut(t));; } // Quint if (easingFunction == Type.EaseInQuint) { return(Quintic.In(t)); } if (easingFunction == Type.EaseOutQuint) { return(Quintic.Out(t)); } if (easingFunction == Type.EaseInOutQuint) { return(Quintic.InOut(t)); } // Sine if (easingFunction == Type.EaseInSine) { return(Sinusoidal.In(t)); } if (easingFunction == Type.EaseOutSine) { return(Sinusoidal.Out(t)); } if (easingFunction == Type.EaseInOutSine) { return(Sinusoidal.InOut(t)); } // Expo if (easingFunction == Type.EaseInExpo) { return(Exponential.In(t)); } if (easingFunction == Type.EaseOutExpo) { return(Exponential.Out(t)); } if (easingFunction == Type.EaseInOutExpo) { return(Exponential.InOut(t)); } // CirC if (easingFunction == Type.EaseInCirc) { return(Circular.In(t)); } if (easingFunction == Type.EaseOutCirc) { return(Circular.Out(t)); } if (easingFunction == Type.EaseInOutCirc) { return(Circular.InOut(t)); } // Linear if (easingFunction == Type.Linear) { return(Linear(t)); } // Bounce if (easingFunction == Type.EaseInBounce) { return(Bounce.In(t)); } if (easingFunction == Type.EaseOutBounce) { return(Bounce.Out(t)); } if (easingFunction == Type.EaseInOutBounce) { return(Bounce.InOut(t)); } // Back if (easingFunction == Type.EaseInBack) { return(Back.In(t)); } if (easingFunction == Type.EaseOutBack) { return(Back.Out(t)); } if (easingFunction == Type.EaseInOutBack) { return(Back.InOut(t)); } // Elastic if (easingFunction == Type.EaseInElastic) { return(Elastic.In(t)); } if (easingFunction == Type.EaseOutElastic) { return(Elastic.Out(t)); } if (easingFunction == Type.EaseInOutElastic) { return(Elastic.InOut(t)); } return(0); }