public static double AngleRad(Point point1, Point point2, Point point3) { double rad = AngleRad(point2.Subtract(point1), point2.Subtract(point3)); double rad2 = AngleRad(point2.Subtract(point1), (point2.Subtract(point3)).RightAngle()); if (rad2 < (Math.PI / 2)) { return rad; } else { return (Math.PI * 2) - rad; } }
/// <summary> /// Place shirt to (x - width*(1/2), y - 10) of specified destination, with a specific height and width /// </summary> /// <param name="destination">The point we will be using to shift and place the shirt</param> /// <param name="width">The desired width of the image</param> /// <param name="height">The desired height of the image</param> public void PlaceShirtToPoint(Point destination, double width, double height) { // determine the difference between the newly requested destination and the previous destination double difference = Point.Subtract(this.previousDestination, destination).Length; if (difference < 1.5) { this.previousDestination = destination; return; } this.ShirtCanvas.Children.Clear(); double x = destination.X - (width / 2); double y = destination.Y - 10; using (DrawingContext dc = this.shirtDrawing.RenderOpen()) { dc.DrawImage( this.ShirtBitmapSource, new Rect(x, y, width, height)); } this.ShirtCanvas.Children.Add(this.visualHost); // track previous point, could be better to use moving average but ⏳ this.previousDestination = destination; }
public void DrawFaceModel(DrawingContext drawingContext) { if (!this.lastFaceTrackSucceeded || this.skeletonTrackingState != SkeletonTrackingState.Tracked) { return; } var faceModelPts = new List <Point>(); for (int i = 0; i < this.facePoints.Count; i++) { faceModelPts.Add(new Point(this.facePoints[i].X + 0.5f, this.facePoints[i].Y + 0.5f)); } // Added drawingContext.DrawLine(new Pen(Brushes.LightGreen, 1.0), new Point(faceModelPts[88].X, faceModelPts[88].Y), new Point(faceModelPts[89].X, faceModelPts[89].Y)); //Left drawingContext.DrawEllipse(Brushes.LightGreen, new Pen(Brushes.DarkGreen, 2), new Point(faceModelPts[88].X, faceModelPts[88].Y), 5, 5); //Right drawingContext.DrawEllipse(Brushes.LightGreen, new Pen(Brushes.DarkGreen, 2), new Point(faceModelPts[89].X, faceModelPts[89].Y), 5, 5); _mouthWidth = Point.Subtract(new Point(faceModelPts[88].X, faceModelPts[88].Y), new Point(faceModelPts[89].X, faceModelPts[89].Y)).Length; _noseWidth = Point.Subtract(new Point(faceModelPts[92].X, faceModelPts[92].Y), new Point(faceModelPts[93].X, faceModelPts[93].Y)).Length; // Added }
public static bool Animate( Point currentValue, Vector currentVelocity, Point targetValue, double attractionFator, double dampening, double terminalVelocity, double minValueDelta, double minVelocityDelta, out Point newValue, out Vector newVelocity) { Vector diff = targetValue.Subtract(currentValue); if (diff.Length > minValueDelta || currentVelocity.Length > minVelocityDelta) { newVelocity = currentVelocity * (1 - dampening); newVelocity += diff * attractionFator; if (currentVelocity.Length > terminalVelocity) { newVelocity *= terminalVelocity / currentVelocity.Length; } newValue = currentValue + newVelocity; return true; } else { newValue = targetValue; newVelocity = new Vector(); return false; } }
private static Point ReflectPointIn(Point point, Point anchor) { Vector magnitude = Point.Subtract(point, anchor); // Reflect magnitude.Negate(); return(Point.Add(anchor, magnitude)); }
public static bool IsMovedALot(Point originLocation, Point newLocation, out Point dif) { dif = originLocation.Subtract(newLocation); if (dif.X > 400 || dif.X < -400 || dif.Y > 400 || dif.Y < -400) { return true; } return false; }
private void Grid_MouseMove(object sender, MouseEventArgs e) { if (!HideGrid.IsMouseCaptured) { return; } Vector offset = Point.Subtract(e.GetPosition(MouseGrid), _currentLocation); Tt.X = moveOffset.X + offset.X; Tt.Y = moveOffset.Y + offset.Y; }
private List <Tuple <Vector, Vector> > CalculateDeltas(List <Tuple <Point, Point> > sourceLines, List <Tuple <Point, Point> > destLines) { List <Tuple <Vector, Vector> > deltas = new List <Tuple <Vector, Vector> >(); for (int i = 0; i < sourceLines.Count; i++) { Vector vec1 = Point.Subtract(destLines[i].Item1, sourceLines[i].Item1); Vector vec2 = Point.Subtract(destLines[i].Item2, sourceLines[i].Item2); vec1 = Vector.Divide(vec1, numFrames); vec2 = Vector.Divide(vec2, numFrames); deltas.Add(new Tuple <Vector, Vector>(vec1, vec2)); } return(deltas); }
private void timer1_Tick(object sender, EventArgs e) { //判定ロケーションをリセット button2.Location = new System.Drawing.Point(-32, -32); //プレイヤー動作関数呼び出し MarionMove(); //仮プレイヤー //this.Text = "" + MovetriggerUp + MovetriggerDown + MovetriggerRight + MovetriggerLeft + Marion.MarionSpeed // +":"+(Marion.MarionX/32+Marion.MarionY/32*30); //プレイヤーの現在マスを格納 Marion.MarionMass = Marion.MarionX / 32 + Marion.MarionY / 32 * 30; //ここまで// //移動範囲制限 if (Marion.MarionX <= 0) { Marion.MarionX = 0; } if (Marion.MarionX >= 928) { Marion.MarionX = 928; } if (Marion.MarionY <= 0) { Marion.MarionY = 0; } if (Marion.MarionY >= 608) { Marion.MarionY = 608; } //空間分割配列リセット SpaceMapMass = new Space[600]; //ステージパネルをずらす if (StageScrollSW == 0) { StageScroll--; /* * status.Location = new System.Drawing.Point(Math.Abs(StageScroll), 0); * if(StageScroll % -10 == 0) * { * scores += 10; * } */ } //ステージパネルの0番目の座標が1パネル分ずれる度 if (StageScroll == (-1 * STAGE.MapX * STAGE.MapChip) * ScrollMapPanel) { //スクロールパネル判定を加算 ScrollMapPanel++; } //ステージパネルの枚数分 for (int i = 0; i < (int)STAGE.StagePanel.Stage1panel; i++) { // ステージパネルの0番目の座標が一定以下になったら // ステージスクロールスイッチをオンに(スクロール停止). if (StageScroll <= -1 * ((((int)STAGE.StagePanel.Stage1panel) - 1) * STAGE.MapX * STAGE.MapChip)) { //スクロールスイッチオン StageScrollSW = 1; } // ステージスクロールスイッチがオフのときは // スクロール. if (StageScrollSW == 0) { //当たり判定をずらす for (int hanteii = 0; hanteii < HanteiPos[i].Length; hanteii++) { //Xをずらす HanteiPos[i][hanteii] = (Point)Point.Subtract(HanteiPos[i][hanteii], Mainus); if (HanteiPos[i][hanteii].X > 0 && HanteiPos[i][hanteii].X < 928) { double berons = (HanteiPos[i][hanteii].X / 32 + (HanteiPos[i][hanteii].Y - 32) / 32 * 30); SpaceMapMass[(int)Math.Round(berons, MidpointRounding.AwayFromZero)].PointX = (int)HanteiPos[i][hanteii].X; SpaceMapMass[(int)Math.Round(berons, MidpointRounding.AwayFromZero)].PointY = (int)HanteiPos[i][hanteii].Y; SpaceMapMass[(int)Math.Round(berons, MidpointRounding.AwayFromZero)].MapNum = HanteiNums[i][hanteii]; } } // ステージパネルをスクロール. StagePanel.Left = StageScroll; } } this.Text = ":" + Marion.MarionX + ":" + Marion.MarionY; //当たり判定設定関数実行 CollisionCheck(); //判定可視化用のボタンスクロール button2.Location = new System.Drawing.Point(button2.Location.X - 1, button2.Location.Y); //描写リセット(Paintイベント呼び出し) StagePanel.Refresh(); }