예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }