static void Main(string[] args) { Console.WriteLine("Hello!"); P1 solver = new P1(); //Console.WriteLine("P1: " + solver.p1()); //Console.WriteLine("P2: " + solver.p2()); Console.WriteLine("P3: " + solver.p3()); }
public float DistanceSquared(Vector2f p) { float t = (p - Center).Dot(Direction); if (t >= Extent) { return(P1.DistanceSquared(p)); } else if (t <= -Extent) { return(P0.DistanceSquared(p)); } Vector2f proj = Center + t * Direction; return((proj - p).LengthSquared); }
public double DistanceSquared(Vector3d p) { double t = (p - Center).Dot(Direction); if (t >= Extent) { return(P1.DistanceSquared(p)); } else if (t <= -Extent) { return(P0.DistanceSquared(p)); } Vector3d proj = Center + t * Direction; return((proj - p).LengthSquared); }
public double DistanceSquared(Vector2d p, out double t) { t = (p - Center).Dot(Direction); if (t >= Extent) { t = Extent; return(P1.DistanceSquared(p)); } else if (t <= -Extent) { t = -Extent; return(P0.DistanceSquared(p)); } Vector2d proj = Center + t * Direction; return(proj.DistanceSquared(p)); }
private static void a() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool result = c.b().Result; if (result) { P1 p = new P1(); p.Show(); Application.Run(); } else { Application.Exit(); } }
public void TapLlanowarElvesToAddOneGreenManaToPool() { var elves = C("Llanowar elves"); Hand(P1, elves); Exec( At(Step.FirstMain) .Cast(elves), At(Step.FirstMain, turn: 3) .Activate(elves) .Verify(() => { True(P1.Battlefield.Contains(elves)); True(P1.HasMana(Mana.Green)); })); }
public override void rsc(int i, int h, MappedInStream @in) { container.Container[] d = ((P0)owner).Data; SetType <container.SomethingElse> type = (SetType <container.SomethingElse>) this.type.cast <container.SomethingElse, System.Object>(); P1 t = ((P1)(object)type.groundType); for (; i != h; i++) { int size = @in.v32(); System.Collections.Generic.HashSet <container.SomethingElse> v = new HashSet <container.SomethingElse>(); while (size-- > 0) { v.Add((container.SomethingElse)t.getByID(@in.v32())); } d[i].someSet = v; } }
public override bool Equals(object obj) { return(obj is Triangle triangle && Transform.Equals(triangle.Transform) && Material.Equals(triangle.Material) && Parent == triangle.Parent && HasParent == triangle.HasParent && P1.Equals(triangle.P1) && P2.Equals(triangle.P2) && P3.Equals(triangle.P3) && Edge1.Equals(triangle.Edge1) && Edge2.Equals(triangle.Edge2) && Normal.Equals(triangle.Normal) && N1.Equals(triangle.N1) && N2.Equals(triangle.N2) && N3.Equals(triangle.N3) && IsSmoothed == triangle.IsSmoothed); }
private void ProcessTurn() { if (gamestate.currentPlayer.Equals(FieldObject.P1)) { P1.SetGameState(ConvertGameState(gamestate)); timeoutplayer1.SetGameState(ConvertGameState(gamestate)); } else if (gamestate.currentPlayer.Equals(FieldObject.P2)) { //gamestateを反転して渡す P2.SetGameState(ConvertGameState(gamestate)); timeoutplayer2.SetGameState(ConvertGameState(gamestate)); } MovePlayer(); }
public void DescribeTo() { P1 p1 = new P1(); P2 p2 = new P2(); S1 s1 = new S1(); S2 s2 = new S2(); this.testee.Register(p1); this.testee.Register(p2); this.testee.Register(s1); this.testee.Register(s2); StringWriter writer = new StringWriter(); this.testee.DescribeTo(writer); writer.Close(); writer.ToString(); }
//https://www.geeksforgeeks.org/is-vs-as-operator-keyword-in-c-sharp/ private void BtnIsOp_Click(object sender, RoutedEventArgs e) { // creating an instance // of class P P o1 = new P(); // creating an instance // of class P1 P1 o2 = new P1(); // checking whether 'o1' // is of type 'P' Debug.WriteLine(o1 is P); // checking whether 'o1' is // of type Object class // (Base class for all classes) Debug.WriteLine(o1 is Object); // checking whether 'o2' // is of type 'P1' Debug.WriteLine(o2 is P1); // checking whether 'o2' is // of type Object class // (Base class for all classes) Debug.WriteLine(o2 is Object); // checking whether 'o2' // is of type 'P' // it will return true as P1 // is derived from P Debug.WriteLine(o2 is P1); // checking whether o1 // is of type P2 // it will return false Debug.WriteLine(o1 is P2); // checking whether o2 // is of type P2 // it will return false Debug.WriteLine(o2 is P2); }
public Vector SnapToLine(Vector pos, LineSnapDirection snapMode = LineSnapDirection.Perpendicular, bool infiniteLine = true) { Vector result = Vector.Empty; if (snapMode == LineSnapDirection.Horizontal) { result = Equation.GetPointForY(pos.Y); } else if (snapMode == LineSnapDirection.Vertical) { result = Equation.GetPointForX(pos.X); } else { var perp = Line.GetPerpendicular(Equation, pos); Equation.Intersect(perp, out result); } if (!result.IsEmpty && !infiniteLine) { var v1 = result - P1.ToVector(); var v2 = result - P2.ToVector(); if (!v1.Normalized.EqualOrClose(Direction, 0.0001)) { return(snapMode == LineSnapDirection.Perpendicular ? P1.ToVector() : Vector.Empty); } else if (v1.Length > Length.NormalizedValue) { return(snapMode == LineSnapDirection.Perpendicular ? P2.ToVector() : Vector.Empty); } if (!v2.Normalized.EqualOrClose(Direction * -1, 0.0001)) { return(snapMode == LineSnapDirection.Perpendicular ? P2.ToVector() : Vector.Empty); } else if (v2.Length > Length.NormalizedValue) { return(snapMode == LineSnapDirection.Perpendicular ? P1.ToVector() : Vector.Empty); } } return(result); }
/// <summary> /// Interpolate a Bezier segment with a given precision /// </summary> /// <param name="i">Index first point of Bezier segment</param> /// <param name="precision">precision</param> /// <param name="points">List of points where to add new points for the segment</param> private void InterpolateSegment(int i, double precision, List <PointD> points) { PointD P0, P1, P2, P3; double maxMedianLengthSqr = Math.Max( ControlPoints[i + 1].Median(ControlPoints[i], ControlPoints[i + 2]).LengthSqr(), ControlPoints[i + 2].Median(ControlPoints[i + 1], ControlPoints[i + 3]).LengthSqr() ); if (maxMedianLengthSqr <= 0.25 * precision * precision) { points.Add(ControlPoints[i + 3]); return; } double cnt = Math.Min((int)Math.Sqrt(Math.Sqrt(maxMedianLengthSqr) / precision) + 3, 1500); double d = 1 / cnt; P0 = ControlPoints[i]; P1 = DeCasteljau(i, d); points.Add(P1); P2 = DeCasteljau(i, 2 * d); points.Add(P2); P3 = DeCasteljau(i, 3 * d); points.Add(P3); P0 = P1.Substract(P0); P1 = P2.Substract(P1); P2 = P3.Substract(P2); // P0 = P1.Substract(P0); P1 = P2.Substract(P1); // P0 = P1.Substract(P0); for (int j = 4; j <= (int)cnt; j++) { P1 = P1.Addition(P0); P2 = P2.Addition(P1); P3 = P3.Addition(P2); points.Add(P3); } }
static void Medium() { LibraryDealer ld = new LibraryDealer(@"D:\C#\C-Msterials\W11\AsciiArt"); Token peko = new Token(ld.Txt2AsciiString("1.txt"), "N_Ghy"); Token miko = new Token(ld.Txt2AsciiString("2.txt"), "O_Ghy"); // --- Console.WriteLine("{0}'s status is", peko.Name); peko.status.ShowStatus(); Console.WriteLine("--------------------"); Console.WriteLine("{0}'s status is", miko.Name); miko.status.ShowStatus(); Console.WriteLine("--------------------"); BigWar(peko, miko); // Because classes are reference types, someone's Hp becomes to 0 now. void BigWar(Token P1, Token P2) {// PekoMiko Daisensou /* 是說關於RPG中,物件間的對戰, * 同學可以盡情發揮創意, * 利用添加不同的properties給物件, * 來自創各種遊戲的戰鬥系統。 * 例如:Status若再加入int spd 代表腳色的速度能力值, * 那我們這邊BigWar函式,就可以根據物件.status.spd決定誰先攻。 */ while (true) { P2.Defence(P1.Attack()); if (P2.status.Hp <= 0) { Console.WriteLine("K.O.\n{0}\n{1} is winner", P1.Art, P1.Name); break; } Console.WriteLine(); P1.Defence(P2.Attack()); if (P1.status.Hp <= 0) { Console.WriteLine("K.O.\n{0}\n{1} is winner", P2.Art, P2.Name); break; } Console.WriteLine("--------------------"); } }// Big War }
public void AddOneAnyManaToPool() { var bird = C("Birds of Paradise"); Battlefield(P1, bird); Exec( At(Step.FirstMain) .Activate(bird) .Verify(() => { True(P1.HasMana(Mana.White)); True(P1.HasMana(Mana.Blue)); True(P1.HasMana(Mana.Black)); True(P1.HasMana(Mana.Red)); True(P1.HasMana(Mana.Green)); }) ); }
/// <summary> /// Computes the closest point on this line segment to another point. /// </summary> /// <param name="p">The point to find the closest point to.</param> /// <returns> /// A Coordinate which is the closest point on the line segment to the point p. /// </returns> public ICoordinate ClosestPoint(ICoordinate p) { double factor = ProjectionFactor(p); if (factor > 0 && factor < 1) { return(Project(p)); } double dist0 = P0.Distance(p); double dist1 = P1.Distance(p); if (dist0 < dist1) { return(P0); } else { return(P1); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MoveMouse(object sender, EventArgs e) { //Valeurs du positionnement de la souris int iX = PointToClient(MousePosition).X; int iY = PointToClient(MousePosition).Y; int iDiff = 15; //Taille des lignes graphiques //Création des chemins (lignes) graphiques P.AddLine(iLastX - iDiff, iLastY - iDiff, iX + iDiff, iY + iDiff); P1.AddLine(iLastX + iDiff, iLastY + iDiff, iX - iDiff, iY - iDiff); P2.AddLine(iLastX - iDiff, iLastY - iDiff, iX - iDiff, iY - iDiff); P3.AddLine(iLastX + iDiff, iLastY + iDiff, iX + iDiff, iY + iDiff); //Dernières valeurs du positionnement de la souris iLastX = iX; iLastY = iY; Invalidate(); //Mise à jour des chemins graphiques }
IEnumerable orto_shift(double d) { Point P1; var shift_dir = new Vector2d(-dir.y, dir.x); var _xtol = d / 100; while (Math.Abs(d) > _xtol) { P1 = P + shift_dir * d; P1.Update(); yield return(null); if (P1.IsFeasible) { P = P1; break; } d /= -2; } }
public override int GetHashCode() { int hashCode = -2063967696; hashCode = hashCode * -1521134295 + Transform.GetHashCode(); hashCode = hashCode * -1521134295 + Material.GetHashCode(); hashCode = hashCode * -1521134295 + SavedRay.GetHashCode(); hashCode = hashCode * -1521134295 + Parent.GetHashCode(); hashCode = hashCode * -1521134295 + HasParent.GetHashCode(); hashCode = hashCode * -1521134295 + P1.GetHashCode(); hashCode = hashCode * -1521134295 + P2.GetHashCode(); hashCode = hashCode * -1521134295 + P3.GetHashCode(); hashCode = hashCode * -1521134295 + Edge1.GetHashCode(); hashCode = hashCode * -1521134295 + Edge2.GetHashCode(); hashCode = hashCode * -1521134295 + Normal.GetHashCode(); hashCode = hashCode * -1521134295 + N1.GetHashCode(); hashCode = hashCode * -1521134295 + N2.GetHashCode(); hashCode = hashCode * -1521134295 + N3.GetHashCode(); hashCode = hashCode * -1521134295 + IsSmoothed.GetHashCode(); return(hashCode); }
public void GetRegrasProducao() { bool repeat = true; while (repeat) { Console.WriteLine("\nDigite as regras de produção seguindo o exemplo: S>AB, A>aA, Bb>bB"); Aux = Console.ReadLine().Replace(" ", string.Empty).Split(',').ToList(); foreach (string s in Aux) { if (s.Length > 2) { P0.Add(s.Split('>')[0]); P1.Add(s.Split('>')[1]); } } repeat = CheckRegrasProducao(); } }
public void AutoImplementedPropertyTest() { P0 p0 = new P0(); P1 p1 = new P1(); Stopwatch watch = new Stopwatch(); watch.Restart(); for (int i = 0; i < 100000000; ++i) { p0.Field = i; } Trace.WriteLine(watch.ElapsedTicks); watch.Restart(); for (int i = 0; i < 100000000; ++i) { p1.Field = i; } Trace.WriteLine(watch.ElapsedTicks); }
public override ArrayList GetItemInfo() { ArrayList itemInfo = new ArrayList { new InputText(this, "P1:", P1.ToString(), true, "p1"), new InputText(this, "U1:", U1.ToString(), true, "u1"), new InputText(this, "V1:", V1.ToString(), true, "v1"), new InputText(this, "P2:", P2.ToString(), true, "p2"), new InputText(this, "U2:", U2.ToString(), true, "u2"), new InputText(this, "V2:", V2.ToString(), true, "v2"), new InputText(this, "P3:", P3.ToString(), true, "p3"), new InputText(this, "U3:", U3.ToString(), true, "u3"), new InputText(this, "V3:", V3.ToString(), true, "v3"), new InputText(this, "Material:", Enum.GetName(typeof(P3DMaterial), Material), false, ""), }; return(itemInfo); }
private async Task <bool> InternalToggle(P1 pin) { var tcs = new TaskCompletionSource <bool>(); try { // set value to true Pi.Gpio[pin].PinMode = GpioPinDriveMode.Output; Pi.Gpio[pin].Value = true; Debug.WriteLine($"Set {pin} to ON"); // reset the pin status to off var resetTimer = new System.Timers.Timer(2000); resetTimer.Elapsed += Callback; resetTimer.AutoReset = false; resetTimer.Start(); } catch { Debug.WriteLine($"Could not toggle slot {pin} on Raspberry PI Hardware"); tcs.SetResult(false); } void Callback(object sender, ElapsedEventArgs e) { try { Pi.Gpio[pin].Value = false; tcs.SetResult(true); Debug.WriteLine($"Reset {pin} to OFF"); } catch { Debug.WriteLine($"Could not reset slot {pin} to off."); tcs.SetResult(false); } } return(await tcs.Task); }
/// <summary> /// <para>Копирование значений простых полей с одинаковыми именами в другой объект.</para> /// <para>Копируются только public поля.</para> /// </summary> public static T CopyFieldsTo <T>(this object self, T obj, bool ignoreNulls = false) where T : class { if (self == null || obj == null) { return(obj); } var T1 = self.GetType(); var T2 = obj.GetType(); var PL1 = T1.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); var PL2 = T2.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); foreach (var P1 in PL1) { if (P1.FieldType.IsPrimitive || P1.FieldType == typeof(String) || P1.FieldType == typeof(DateTime)) { var V = P1.GetValue(self); if (ignoreNulls && V.IsNull()) { continue; } if (T1 == T2) { P1.SetValue(obj, V); } else { foreach (var P2 in PL2) { if (P2.Name == P1.Name) { P2.SetValue(obj, V); break; } } } } } return(obj); }
public int CompareTo(object obj) { IP comp = (IP)obj; int result = P1.CompareTo(comp.P1); if (result != 0) { return(result); } result = P2.CompareTo(comp.P2); if (result != 0) { return(result); } result = P3.CompareTo(comp.P3); if (result != 0) { return(result); } result = P4.CompareTo(comp.P4); return(result); }
IEnumerable <RendezvousTrajectory> orto_shift(double shift_delta) { var shift_dir = new Vector2d(-dir.y, dir.x); shift_delta = Math.Min(shift_delta, 100); Point P1; while (Math.Abs(shift_delta) > 1e-5) { P1 = P + shift_dir * shift_delta; P1.UpdateTrajectory(); yield return(P1.trajectory); if (feasible_point(P1)) { P1.UpdateDist(); P = P1; break; } shift_delta /= -2; } }
public override int GetHashCode() { var hashCode = 162377905; int p1h = P1 /*.Rounded(4)*/.GetHashCode(); int p2h = P2 /*.Rounded(4)*/.GetHashCode(); if (p1h < p2h) { hashCode = hashCode * -1521134295 + p1h; hashCode = hashCode * -1521134295 + p2h; } else { hashCode = hashCode * -1521134295 + p2h; hashCode = hashCode * -1521134295 + p1h; } hashCode = hashCode * -1521134295 + EdgeNormal.GetHashCode(); hashCode = hashCode * -1521134295 + FaceNormal.GetHashCode(); return(hashCode); }
/// <summary> /// allocate correct pool type and add it to types /// </summary> internal static AbstractStoragePool newPool(string name, AbstractStoragePool superPool, List <AbstractStoragePool> types) { try { switch (name) { case "testenum": return(superPool = new P0(types.Count)); case "testenum:default": return(superPool = new P1(types.Count, (P0)superPool)); case "testenum:second": return(superPool = new P2(types.Count, (P0)superPool)); case "testenum:third": return(superPool = new P3(types.Count, (P0)superPool)); case "testenum:last": return(superPool = new P4(types.Count, (P0)superPool)); default: if (null == superPool) { return(superPool = new BasePool <SkillObject>(types.Count, name, AbstractStoragePool.noKnownFields, AbstractStoragePool.NoAutoFields)); } else { return(superPool = superPool.makeSubPool(types.Count, name)); } } } finally { types.Add(superPool); } }
/// <summary> /// allocate correct pool type and add it to types /// </summary> internal static AbstractStoragePool newPool(string name, AbstractStoragePool superPool, List <AbstractStoragePool> types) { try { switch (name) { case "a": return(superPool = new P0(types.Count)); case "b": return(superPool = new P1(types.Count, (P0)superPool)); case "c": return(superPool = new P2(types.Count, (P1)superPool)); case "d": return(superPool = new P3(types.Count, (P1)superPool)); case "noserializeddata": return(superPool = new P4(types.Count)); default: if (null == superPool) { return(superPool = new BasePool <SkillObject>(types.Count, name, AbstractStoragePool.noKnownFields, AbstractStoragePool.NoAutoFields)); } else { return(superPool = superPool.makeSubPool(types.Count, name)); } } } finally { types.Add(superPool); } }
protected override void Check() { _x = 2; P1.ShouldBe(4); P3.ShouldBe(1); _x = 10; P1.ShouldBe(20); P3.ShouldBe(5); P2.ShouldBe(77); var c1 = new C(7); c1.P.ShouldBe(7); var c2 = new C(77); c2.P.ShouldBe(77); P4 = 9; P4.ShouldBe(9); P4 = 11; P4.ShouldBe(11); P5 = 13; _x.ShouldBe(13); P5 = 131; _x.ShouldBe(131); P6 = 16; P6.ShouldBe(16); P6 = 8; P6.ShouldBe(8); }
private void AnimeDie_Tick_1(object sender, EventArgs e) { counting++; if (counting == 1) { Image img; img = Image.FromFile("" + 20 + ".gif"); P1.Image = img; } if (counting == 2) { Image img; img = Image.FromFile("" + 21 + ".gif"); P1.Image = img; } if (counting == 3) { Image img; img = Image.FromFile("" + 22 + ".gif"); P1.Image = img; } if (counting == 4) { Image img; img = Image.FromFile("" + 23 + ".gif"); P1.Image = img; } if (counting == 5) { Image img; img = Image.FromFile("" + 24 + ".gif"); P1.Image = img; } if (counting > 5) { P1.Dispose(); } }
private void HighMirror (P1, P2: Pointer) { // type // PlaneBuffer = array[0..2 * H - 1, 0..W div 4 - 1] of Byte; // PlaneBufferArray = array[0..3] of PlaneBuffer; // PlaneBufferArrayPtr = ^PlaneBufferArray; // var // Source, Dest: PlaneBufferArrayPtr; // private void Swap (Plane1, Plane2: Byte); // var // i, j: Byte; // begin // for j := 0 to 2 * H - 1 do // for i := 0 to W div 4 - 1 do // begin // Dest^[Plane2, j, i] := Source^[Plane1, j, W div 4 - 1 - i]; // Dest^[Plane1, j, i] := Source^[Plane2, j, W div 4 - 1 - i]; // end; // end; // begin // Source := P1; // Dest := P2; // Swap (0, 3); // Swap (1, 2); // end; }
private void Mirror20x24 (P1, P2: Pointer) { const W = 20; H = 24; type PlaneBuffer = array[0..H - 1, 0..W div 4 - 1] of Byte;
private void ReColor(P1, P2: Pointer; C: Byte)