private void ManipulateRotating() { MouseState mouseState = Mouse.GetState(); { if (!_firstTimePressed) { if (mouseState.RightButton == ButtonState.Pressed) { _firstTimePressed = true; _vectorStart = new Vector2(mouseState.X, mouseState.Y); _vectorStart.Normalize(); } } if (_firstTimePressed) { if (mouseState.RightButton == ButtonState.Pressed) { Vector2 vectorEnd = new Vector2(mouseState.X, mouseState.Y); vectorEnd.Normalize(); float angle = MathHelperModule.GetAngleBetweenTwoVectors(_vectorStart, vectorEnd); CurrentVisual2DResize.SetOrientation(angle); } } } }
public static void SetProperHalfFarWidth(SpringService rope, CookieRB cookieRb, out int verticalLineLength, out int halfFarWidth) { var ropeVec = rope.Masses[0].PositionXNACenter2D; var cookieVec = cookieRb.PositionXNACenter2D; var hypotenuseVec = Vector2.Subtract(cookieVec, ropeVec); hypotenuseVec.Normalize(); Vector2 verticalLine = new Vector2(0, 1); float angleRopeHead = MathHelper.ToDegrees(MathHelperModule.GetAngleBetweenTwoVectors(verticalLine, hypotenuseVec)) - 9; angleRopeHead = angleRopeHead < 0 ? 1 : angleRopeHead; float angleElse = 180 - 90 - angleRopeHead; int hypotenuseVecLength = 2000; verticalLineLength = (int)(hypotenuseVecLength * (angleElse / 90)); halfFarWidth = (int)Math.Sqrt(Math.Pow(hypotenuseVecLength, 2) - Math.Pow(verticalLineLength, 2)); }