当前位置: 首页>>代码示例>>C#>>正文


C# CelestialBody.GetSurfaceNVector方法代码示例

本文整理汇总了C#中CelestialBody.GetSurfaceNVector方法的典型用法代码示例。如果您正苦于以下问题:C# CelestialBody.GetSurfaceNVector方法的具体用法?C# CelestialBody.GetSurfaceNVector怎么用?C# CelestialBody.GetSurfaceNVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CelestialBody的用法示例。


在下文中一共展示了CelestialBody.GetSurfaceNVector方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: drawLandingArea

        public static void drawLandingArea(CelestialBody body, double minLatitude, double maxLatitude, 
                                            double minLongitude, double maxLongitude, 
                                            Color c, double rotation = 0)
        {
            double dlat = (maxLatitude - minLatitude) / 10.0;
            double dlog = (maxLongitude - minLongitude) / 10.0;

            List<Vector3d[]> quads = new List<Vector3d[]> ();

            for (double lat = minLatitude; lat + dlat < maxLatitude; lat += dlat) {
                for (double log = minLongitude; log + dlog < maxLongitude; log += dlog) {
                    Vector3d up1 = body.GetSurfaceNVector (lat, log);
                    Vector3d center1 = body.position + body.Radius * up1;

                    Vector3d up2 = body.GetSurfaceNVector (lat, log + dlog);
                    Vector3d center2 = body.position + body.Radius * up2;

                    Vector3d up3 = body.GetSurfaceNVector (lat + dlat, log + dlog);
                    Vector3d center3 = body.position + body.Radius * up3;

                    Vector3d up4 = body.GetSurfaceNVector (lat + dlat, log);
                    Vector3d center4 = body.position + body.Radius * up4;

                    if (!IsOccluded (center1, body)) {
                        quads.Add (new Vector3d[] { center1, center2, center3, center4});
                    }
                }
            }

            GLQuadMap (quads, c);
        }
开发者ID:jwvanderbeck,项目名称:KSPMissionController,代码行数:31,代码来源:GLUtils.cs

示例2: DrawMapViewGroundMarker

        public static void DrawMapViewGroundMarker(CelestialBody body, double latitude, double longitude, Color c, double rotation = 0, double radius = 0)
        {
            Vector3d up = body.GetSurfaceNVector(latitude, longitude);
            var height = body.pqsController.GetSurfaceHeight(QuaternionD.AngleAxis(longitude, Vector3d.down) * QuaternionD.AngleAxis(latitude, Vector3d.forward) * Vector3d.right);
            if (height < body.Radius) { height = body.Radius; }
            Vector3d center = body.position + height * up;

            if (IsOccluded(center, body)) return;

            Vector3d north = Vector3d.Exclude(up, body.transform.up).normalized;

            if (radius <= 0) { radius = body.Radius / 15; }

            GLTriangleMap(new Vector3d[]{
                center,
                center + radius * (QuaternionD.AngleAxis(rotation - 10, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation + 10, up) * north)
            }, c);

            GLTriangleMap(new Vector3d[]{
                center,
                center + radius * (QuaternionD.AngleAxis(rotation + 110, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation + 130, up) * north)
            }, c);

            GLTriangleMap(new Vector3d[]{
                center,
                center + radius * (QuaternionD.AngleAxis(rotation - 110, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation - 130, up) * north)
            }, c);
        }
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:31,代码来源:GLUtils.cs

示例3: GetNorthVector

 public static Vector3 GetNorthVector(Vector3 position, CelestialBody body)
 {
     Vector3 geoPosA = VectorUtils.WorldPositionToGeoCoords(position, body);
     Vector3 geoPosB = new Vector3(geoPosA.x+1, geoPosA.y, geoPosA.z);
     Vector3 north = GetWorldSurfacePostion(geoPosB, body)-GetWorldSurfacePostion(geoPosA, body);
     return Vector3.ProjectOnPlane(north, body.GetSurfaceNVector(geoPosA.x, geoPosA.y)).normalized;
 }
开发者ID:jediminer543,项目名称:BDArmory,代码行数:7,代码来源:VectorUtils.cs

示例4: TimeToPhaseAngle

        //Computes the time until the phase angle between the launchpad and the target equals the given angle.
        //The convention used is that phase angle is the angle measured starting at the target and going east until
        //you get to the launchpad.
        //The time returned will not be exactly accurate unless the target is in an exactly circular orbit. However,
        //the time returned will go to exactly zero when the desired phase angle is reached.
        public static double TimeToPhaseAngle(double phaseAngle, CelestialBody launchBody, double launchLongitude, Orbit target)
        {
            double launchpadAngularRate = 360 / launchBody.rotationPeriod;
            double targetAngularRate = 360.0 / target.period;
            if (Vector3d.Dot(target.SwappedOrbitNormal(), launchBody.angularVelocity) < 0) targetAngularRate *= -1; //retrograde target

            Vector3d currentLaunchpadDirection = launchBody.GetSurfaceNVector(0, launchLongitude);
            Vector3d currentTargetDirection = target.SwappedRelativePositionAtUT(Planetarium.GetUniversalTime());
            currentTargetDirection = Vector3d.Exclude(launchBody.angularVelocity, currentTargetDirection);

            double currentPhaseAngle = Math.Abs(Vector3d.Angle(currentLaunchpadDirection, currentTargetDirection));
            if (Vector3d.Dot(Vector3d.Cross(currentTargetDirection, currentLaunchpadDirection), launchBody.angularVelocity) < 0)
            {
                currentPhaseAngle = 360 - currentPhaseAngle;
            }

            double phaseAngleRate = launchpadAngularRate - targetAngularRate;

            double phaseAngleDifference = MuUtils.ClampDegrees360(phaseAngle - currentPhaseAngle);

            if (phaseAngleRate < 0)
            {
                phaseAngleRate *= -1;
                phaseAngleDifference = 360 - phaseAngleDifference;
            }

            return phaseAngleDifference / phaseAngleRate;
        }
开发者ID:ramfreak04,项目名称:MechJeb2,代码行数:33,代码来源:MechJebModuleAscentAutopilot.cs

示例5: DrawMapViewGroundMarker

        public static void DrawMapViewGroundMarker(CelestialBody body, double latitude, double longitude, Color c, double rotation = 0)
        {
            Vector3d up = body.GetSurfaceNVector(latitude, longitude);
            Vector3d center = body.position + body.Radius * up;

            if (IsOccluded(center, body)) return;

            Vector3d north = Vector3d.Exclude(up, body.transform.up).normalized;

            double radius = body.Radius / 15;

            GLTriangleMap(new Vector3d[]{
                center,
                center + radius * (QuaternionD.AngleAxis(rotation - 10, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation + 10, up) * north)
            }, c);

            GLTriangleMap(new Vector3d[]{
                center,
                center + radius * (QuaternionD.AngleAxis(rotation + 110, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation + 130, up) * north)
            }, c);

            GLTriangleMap(new Vector3d[]{
                center,
                center + radius * (QuaternionD.AngleAxis(rotation - 110, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation - 130, up) * north)
            }, c);
        }
开发者ID:Raf04,项目名称:MechJeb2,代码行数:29,代码来源:GLUtils.cs

示例6: RaycastGround

 public static DMPRaycastPair RaycastGround(double latitude, double longitude, CelestialBody body)
 {
     //We can only find the ground on bodies that actually *have* ground and if we are in flight near the origin
     if (!HighLogic.LoadedSceneIsFlight || FlightGlobals.fetch.activeVessel == null || body.pqsController == null)
     {
         return new DMPRaycastPair(-1f, Vector3.up);
     }
     //Math functions take radians.
     double latRadians = latitude * Mathf.Deg2Rad;
     double longRadians = longitude * Mathf.Deg2Rad;
     //Radial vector
     Vector3d surfaceRadial = new Vector3d(Math.Cos(latRadians) * Math.Cos(longRadians), Math.Sin(latRadians), Math.Cos(latRadians) * Math.Sin(longRadians));
     double surfaceHeight = body.pqsController.GetSurfaceHeight(surfaceRadial) - body.pqsController.radius;
     Vector3d origin = body.GetWorldSurfacePosition(latitude, longitude, surfaceHeight + 500);
     //Only return the surface if it's really close.
     double highestHit = double.NegativeInfinity;
     Vector3 rotatedVector = Vector3.up;
     if (Vector3d.Distance(FlightGlobals.fetch.activeVessel.GetWorldPos3D(), origin) < 2500)
     {
         //Down vector
         Vector3d downVector = -body.GetSurfaceNVector(latitude, longitude);
         //Magic numbers!
         LayerMask groundMask = 33792;
         RaycastHit[] raycastHits = Physics.RaycastAll(origin, downVector, 1000f, groundMask);
         foreach (RaycastHit raycastHit in raycastHits)
         {
             if (raycastHit.collider == null)
             {
                 //I don't think this is technically possible, but unity's weird enough that we should probably check this anyway.
                 continue;
             }
             if (raycastHit.collider.name == body.name)
             {
                 continue;
             }
             double hitAltitude = body.GetAltitude(raycastHit.point);
             if ((hitAltitude > highestHit) && (!body.ocean || hitAltitude > 0))
             {
                 highestHit = hitAltitude;
                 rotatedVector = Quaternion.Inverse(body.rotation) * raycastHit.normal;
             }
         }
     }
     if (highestHit == double.NegativeInfinity)
     {
         return new DMPRaycastPair(-1f, Vector3.up);
     }
     else
     {
         return new DMPRaycastPair(highestHit, rotatedVector);
     }
 }
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:52,代码来源:VesselUtil.cs

示例7: DrawGroundMarker

        public static void DrawGroundMarker(CelestialBody body, double latitude, double longitude, Color c, bool map, double rotation = 0, double radius = 0)
        {
            Vector3d up = body.GetSurfaceNVector(latitude, longitude);
            var height = body.pqsController.GetSurfaceHeight(QuaternionD.AngleAxis(longitude, Vector3d.down) * QuaternionD.AngleAxis(latitude, Vector3d.forward) * Vector3d.right);
            if (height < body.Radius) { height = body.Radius; }
            Vector3d center = body.position + height * up;

            Vector3d camPos = map ? ScaledSpace.ScaledToLocalSpace(PlanetariumCamera.Camera.transform.position) : (Vector3d)FlightCamera.fetch.mainCamera.transform.position;

            if (IsOccluded(center, body, camPos)) return;

            Vector3d north = Vector3d.Exclude(up, body.transform.up).normalized;

            if (radius <= 0) { radius = map ? body.Radius / 15 : 5; }

            if (!map)
            {
                Vector3 centerPoint = FlightCamera.fetch.mainCamera.WorldToViewportPoint(center);
                if (centerPoint.z < 0)
                    return;
            }

            GLTriangle(
                center,
                center + radius * (QuaternionD.AngleAxis(rotation - 10, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation + 10, up) * north)
            , c, map);

            GLTriangle(
                center,
                center + radius * (QuaternionD.AngleAxis(rotation + 110, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation + 130, up) * north)
            , c, map);

            GLTriangle(
                center,
                center + radius * (QuaternionD.AngleAxis(rotation - 110, up) * north),
                center + radius * (QuaternionD.AngleAxis(rotation - 130, up) * north)
            , c, map);
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:40,代码来源:GLUtils.cs

示例8: TimeToPlane

        //From MechJeb2
        //Computes the time required for the given launch location to rotate under the target orbital plane.
        //If the latitude is too high for the launch location to ever actually rotate under the target plane,
        //returns the time of closest approach to the target plane.
        //I have a wonderful proof of this formula which this comment is too short to contain.
        internal static double TimeToPlane(CelestialBody launchBody, double launchLatitude, double launchLongitude, Orbit target)
        {
            double inc = Math.Abs(Vector3d.Angle(target.SwappedOrbitNormal(), launchBody.angularVelocity));
            Vector3d b = Vector3d.Exclude(launchBody.angularVelocity, target.SwappedOrbitNormal()).normalized; // I don't understand the sign here, but this seems to work
            b *= launchBody.Radius * Math.Sin(Math.PI / 180 * launchLatitude) / Math.Tan(Math.PI / 180 * inc);
            Vector3d c = Vector3d.Cross(target.SwappedOrbitNormal(), launchBody.angularVelocity).normalized;
            double cMagnitudeSquared = Math.Pow(launchBody.Radius * Math.Cos(Math.PI / 180 * launchLatitude), 2) - b.sqrMagnitude;
            if (cMagnitudeSquared < 0) cMagnitudeSquared = 0;
            c *= Math.Sqrt(cMagnitudeSquared);
            Vector3d a1 = b + c;
            Vector3d a2 = b - c;

            Vector3d longitudeVector = launchBody.GetSurfaceNVector(0, launchLongitude);

            double angle1 = Math.Abs(Vector3d.Angle(longitudeVector, a1));
            if (Vector3d.Dot(Vector3d.Cross(longitudeVector, a1), launchBody.angularVelocity) < 0) angle1 = 360 - angle1;
            double angle2 = Math.Abs(Vector3d.Angle(longitudeVector, a2));
            if (Vector3d.Dot(Vector3d.Cross(longitudeVector, a2), launchBody.angularVelocity) < 0) angle2 = 360 - angle2;

            double angle = Math.Min(angle1, angle2);
            return (angle / 360) * launchBody.rotationPeriod;
        }
开发者ID:Kerbas-ad-astra,项目名称:KerbalAlarmClock,代码行数:27,代码来源:MechJebAscentAutopilot.cs

示例9: isInSafetyBubble

        private bool isInSafetyBubble(Vector3d pos, CelestialBody body, double altitude)
        {
            //Assume Kerbin if body isn't supplied for some reason
            if (body == null) body = FlightGlobals.Bodies.Find(b => b.name == "Kerbin");

            //If KSC out of range, syncing, not at Kerbin, or past ceiling we're definitely clear
            if (kscPosition == Vector3d.zero || syncing || body.name != "Kerbin" || altitude > SAFETY_BUBBLE_CEILING)
                return false;

            //Cylindrical safety bubble -- project vessel position to a plane positioned at KSC with normal pointed away from surface
            Vector3d kscNormal = body.GetSurfaceNVector(-0.102668048654,-74.5753856554);
            double projectionDistance = Vector3d.Dot(kscNormal, (pos - kscPosition)) * -1;
            Vector3d projectedPos = pos + (Vector3d.Normalize(kscNormal)*projectionDistance);

            return Vector3d.Distance(kscPosition, projectedPos) < safetyBubbleRadius;
        }
开发者ID:Jumba,项目名称:KerbalMultiPlayer,代码行数:16,代码来源:KMPManager.cs

示例10: DrawGroundMarker

 static bool DrawGroundMarker(CelestialBody body, Coordinates pos, Color c, float r = IconSize, Texture2D texture = null)
 {
     Vector3d center;
     Camera camera;
     if(MapView.MapIsEnabled)
     {
         //TODO: cache local center coordinates of the marker
         camera = PlanetariumCamera.Camera;
         center = body.position + (body.TerrainAltitude(pos.Lat, pos.Lon)+body.Radius) * body.GetSurfaceNVector(pos.Lat, pos.Lon);
     }
     else
     {
         camera = FlightCamera.fetch.mainCamera;
         center = body.GetWorldSurfacePosition(pos.Lat, pos.Lon, body.TerrainAltitude(pos.Lat, pos.Lon)+GLB.WaypointHeight);
         if(camera.transform.InverseTransformPoint(center).z <= 0) return false;
     }
     return !IsOccluded(center, body) &&
         DrawMarker(camera.WorldToScreenPoint(MapView.MapIsEnabled ? ScaledSpace.LocalToScaledSpace(center) : center), c, r, texture);
 }
开发者ID:Kerbas-ad-astra,项目名称:ThrottleControlledAvionics,代码行数:19,代码来源:NavigationPanel.cs

示例11: CreateAtCurrentTime

 public static ReferenceFrame CreateAtCurrentTime(CelestialBody referenceBody)
 {
     ReferenceFrame ret = new ReferenceFrame();
     ret.lat0lon0AtStart = referenceBody.GetSurfaceNVector(0, 0);
     ret.lat0lon90AtStart = referenceBody.GetSurfaceNVector(0, 90);
     ret.lat90AtStart = referenceBody.GetSurfaceNVector(90, 0);
     ret.epoch = Planetarium.GetUniversalTime();
     ret.referenceBody = referenceBody;
     return ret;
 }
开发者ID:Conti,项目名称:MechJeb2,代码行数:10,代码来源:ReentrySimulation.cs

示例12: UpdateAtCurrentTime

 public void UpdateAtCurrentTime(CelestialBody body)
 {
     lat0lon0AtStart = body.GetSurfaceNVector(0, 0);
     lat0lon90AtStart = body.GetSurfaceNVector(0, 90);
     lat90AtStart = body.GetSurfaceNVector(90, 0);
     epoch = Planetarium.GetUniversalTime();
     referenceBody = body;
 }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:8,代码来源:ReentrySimulation.cs

示例13: isInSafetyBubble

        private bool isInSafetyBubble(Vector3d pos, CelestialBody body, double altitude)
        {
            //Assume Kerbin if body isn't supplied for some reason
            if (body == null)
                body = FlightGlobals.Bodies.Find(b => b.name == "Kerbin");

            //If not at Kerbin or past ceiling we're definitely clear
            if (body.name != "Kerbin" || altitude > SAFETY_BUBBLE_CEILING)
                return false;

            //Cylindrical safety bubble -- project vessel position to a plane positioned at KSC with normal pointed away from surface
            Vector3d kscNormal = body.GetSurfaceNVector(-0.102668048654, -74.5753856554);
            Vector3d kscPosition = body.GetWorldSurfacePosition(-0.102668048654, -74.5753856554, 60);
            Vector3d landingPadPosition = body.GetWorldSurfacePosition(-0.0971978130377757, 285.44237039111, 60);
            Vector3d runwayPosition = body.GetWorldSurfacePosition(-0.0486001121594686, 285.275552559723, 60);
            double projectionDistance = Vector3d.Dot(kscNormal, (pos - kscPosition)) * -1;
            double landingPadDistance = Vector3d.Distance(pos, landingPadPosition);
            double runwayDistance = Vector3d.Distance(pos, runwayPosition);
            Vector3d projectedPos = pos + (Vector3d.Normalize(kscNormal) * projectionDistance);
            return Vector3d.Distance(kscPosition, projectedPos) < safetyBubbleRadius || runwayDistance < MIN_SAFETY_BUBBLE_DISTANCE || landingPadDistance < MIN_SAFETY_BUBBLE_DISTANCE;
        }
开发者ID:vosechu,项目名称:KerbalMultiPlayer,代码行数:21,代码来源:KMPManager.cs

示例14: drawTargetOverlay

		/*These methods borrowed from MechJeb GLUtils: 
		 * https://github.com/MuMech/MechJeb2/blob/master/MechJeb2/GLUtils.cs
		 * 
		*/
		internal static void drawTargetOverlay(CelestialBody body, double latitude, double longitude, Color c)
		{
			double rotation = 0;
			double radius = 0;
			Vector3d up = body.GetSurfaceNVector(latitude, longitude);
			var height = SCANUtil.getElevation(body, longitude, latitude);
			if (height < body.Radius)
				height = body.Radius;
			Vector3d center = body.position + height * up;

			if (occluded(center, body))
				return;

			Vector3d north = Vector3d.Exclude(up, body.transform.up).normalized;

			if (radius <= 0)
				radius = body.Radius / 15;

			GLTriangleMap(new Vector3d[] { center, center + radius * (QuaternionD.AngleAxis(rotation - 55, up) * north), center + radius * (QuaternionD.AngleAxis(rotation -35, up) * north) }, c);

			GLTriangleMap(new Vector3d[] { center, center + radius * (QuaternionD.AngleAxis(rotation + 55, up) * north), center + radius * (QuaternionD.AngleAxis(rotation + 35, up) * north) }, c);

			GLTriangleMap(new Vector3d[] { center, center + radius * (QuaternionD.AngleAxis(rotation - 145, up) * north), center + radius * (QuaternionD.AngleAxis(rotation - 125, up) * north) }, c);

			GLTriangleMap(new Vector3d[] { center, center + radius * (QuaternionD.AngleAxis(rotation + 145, up) * north), center + radius * (QuaternionD.AngleAxis(rotation + 125, up) * north) }, c);
		}
开发者ID:DBT85,项目名称:SCANsat,代码行数:30,代码来源:SCANuiUtil.cs


注:本文中的CelestialBody.GetSurfaceNVector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。