private void button2_Click(object sender, EventArgs e) { MyVector v1 = new MyVector(1, 0, 0); MyVector v2 = new MyVector(0, 1, 0); MyVector rotationAxis; double radians; v1.GetAngleAroundAxis(out rotationAxis, out radians, v2); v2.GetAngleAroundAxis(out rotationAxis, out radians, v1); }
public void FillPie(Brush brush, MyVector centerPoint, double radius, MyVector centerLine, double sweepRadians) { // Turn the centerline and sweep radians into angles that GDI likes MyVector dummy = new MyVector(1, 0, 0); double startDegrees; dummy.GetAngleAroundAxis(out dummy, out startDegrees, centerLine); startDegrees = Utility3D.GetRadiansToDegrees(startDegrees); if (centerLine.Y < 0) { startDegrees *= -1; } double sweepDegrees = Utility3D.GetRadiansToDegrees(sweepRadians); startDegrees -= sweepDegrees / 2d; // Call my overload FillPie(brush, centerPoint, radius, startDegrees, sweepDegrees); }
private void RotateMe(MyVector localPos, MyVector rotateHandle, MyQuaternion rotation2D, MyVector rotateAround3D) { // Get Current Angle double curRadians = MyVector.GetAngleBetweenVectors(rotateHandle, rotation2D.GetRotatedVector(rotateHandle, true)); // Rotate the 2D Handle MyQuaternion newRotationX; rotateHandle.GetAngleAroundAxis(out newRotationX, localPos); rotation2D.StoreNewValues(newRotationX); // Get New Angle double newRadians = MyVector.GetAngleBetweenVectors(rotateHandle, rotation2D.GetRotatedVector(rotateHandle, true)); double rotateRadians = newRadians - curRadians; if (rotation2D.GetRotatedVector(rotateHandle, true).Y < 0) rotateRadians *= -1; // This statement is cheating. I'm using the fact that the rotate handles all lie on the XY plane // Apply the difference to the 3D object (me) this.RotateAroundAxis(this.Rotation.GetRotatedVector(rotateAround3D, true), rotateRadians); }
private List<BallBlip> FindBlipsInCone(MyVector centerWorld, MyVector dirFacingWorld) { List<BallBlip> retVal = new List<BallBlip>(); // Cache some stuff for use inside the loop double halfSweepAngle = _sweepAngle / 2d; double maxDistSquared = _maxDistance * _maxDistance; // Scan for objects in my path foreach (RadarBlip blip in _map.GetAllBlips()) { if (blip.Token == _ship.Token) { // Can't manipulate me continue; } if (blip.CollisionStyle == CollisionStyle.Ghost) { // Ghost blips don't interact with anything continue; } if (!(blip is BallBlip)) { // The blip needs to be at least a ball continue; } MyVector lineBetween = blip.Sphere.Position - centerWorld; if (lineBetween.GetMagnitudeSquared() > maxDistSquared) { // The object is too far away continue; } MyVector rotationAxis; double rotationRadians; dirFacingWorld.GetAngleAroundAxis(out rotationAxis, out rotationRadians, lineBetween); if (rotationRadians > halfSweepAngle) { // The sweep angle is too great (not inside the cone) continue; } // It's inside the cone retVal.Add(blip as BallBlip); } // Exit Function return retVal; }