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


C# Vector3d类代码示例

本文整理汇总了C#中Vector3d的典型用法代码示例。如果您正苦于以下问题:C# Vector3d类的具体用法?C# Vector3d怎么用?C# Vector3d使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Main

    public static unsafe void Main () {
        for (int i = 0; i < BufferSize; i++)
            Vectors[i] = new Vector3d(i * 0.5, (double)i, i * 1.5);

        Console.WriteLine("Add: {0:00000.00}ms", Time(TestAdd));
        Console.WriteLine("Add Overloaded: {0:00000.00}ms", Time(TestAddOverloaded));
    }
开发者ID:GlennSandoval,项目名称:JSIL,代码行数:7,代码来源:OverloadedConstructorsPerfomance.cs

示例2: Perturb

        // Perturb an orbit by a deltaV vector
        public static void Perturb(this Orbit orbit, Vector3d deltaVV, double UniversalTime, double deltaTime)
        {
            // If there is a deltaV, perturb orbit
            if (deltaVV.magnitude <= 0) return;

            // Transpose deltaVV Y and Z to match orbit frame
            Vector3d deltaVV_orbit = deltaVV.xzy;
            Vector3d position = orbit.getRelativePositionAtUT(UniversalTime);
            //Orbit orbit2 = orbit.Clone();
            //orbit2.UpdateFromStateVectors(position, orbit.getOrbitalVelocityAtUT(UniversalTime) + deltaVV_orbit, orbit.referenceBody, UniversalTime);
            //if (!double.IsNaN(orbit2.inclination) && !double.IsNaN(orbit2.eccentricity) && !double.IsNaN(orbit2.semiMajorAxis) && orbit2.timeToAp > deltaTime)
            //{
            //    orbit.inclination = orbit2.inclination;
            //    orbit.eccentricity = orbit2.eccentricity;
            //    orbit.semiMajorAxis = orbit2.semiMajorAxis;
            //    orbit.LAN = orbit2.LAN;
            //    orbit.argumentOfPeriapsis = orbit2.argumentOfPeriapsis;
            //    orbit.meanAnomalyAtEpoch = orbit2.meanAnomalyAtEpoch;
            //    orbit.epoch = orbit2.epoch;
            //    orbit.referenceBody = orbit2.referenceBody;
            //    orbit.Init();
            //    orbit.UpdateFromUT(UniversalTime);
            //}
            //else
            //{
                orbit.UpdateFromStateVectors(position, orbit.getOrbitalVelocityAtUT(UniversalTime) + deltaVV_orbit, orbit.referenceBody, UniversalTime);
                orbit.Init();
                orbit.UpdateFromUT(UniversalTime);
            //}
        }
开发者ID:ABZB,项目名称:KSPInterstellar,代码行数:31,代码来源:OrbitExtensions.cs

示例3: HUDQuad

 public HUDQuad(RenderSet render_set, Vector3d p, Vector3d s)
     : this(render_set, p,
          p + new Vector3d(s.X, 0.0, 0.0),
          p + new Vector3d(s.X, s.Y, 0.0),
          p + new Vector3d(0.0, s.Y, 0.0))
 {
 }
开发者ID:Apelsin,项目名称:positron,代码行数:7,代码来源:HUDQuad.cs

示例4: RunCalculations

    public void RunCalculations(
        Vessel vessel,
        Quaternion gymbal)
    {
        // Calculations thanks to Mechjeb
        Vector3d CoM = vessel.findWorldCenterOfMass();
        Vector3d up = (CoM - vessel.mainBody.position).normalized;
        Vector3d velocityVesselOrbit = vessel.orbit.GetVel();
        Vector3d velocityVesselOrbitUnit = velocityVesselOrbit.normalized;
        Vector3d radialPlus = Vector3d.Exclude(velocityVesselOrbit, up).normalized;
        Vector3d velocityVesselSurface = velocityVesselOrbit - vessel.mainBody.getRFrmVel(CoM);
        Vector3d velocityVesselSurfaceUnit = velocityVesselSurface.normalized;

        RadialPlus = gymbal * radialPlus;
        NormalPlus = gymbal * -Vector3d.Cross(radialPlus, velocityVesselOrbitUnit);
        ProgradeOrbit = gymbal * velocityVesselOrbitUnit;
        ProgradeSurface = gymbal * velocityVesselSurfaceUnit;

        if (vessel.patchedConicSolver.maneuverNodes.Count > 0)
        {
            Vector3d burnVector = vessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(vessel.orbit);
            ManeuverPlus = gymbal * burnVector.normalized;
            ManeuverPresent = true;
        }
        else
        {
            ManeuverPresent = false;
        }
    }
开发者ID:kujuman,项目名称:EnhancedNavBall,代码行数:29,代码来源:CalculationStore.cs

示例5: Reflect

 public static Ray Reflect(Ray incoming, Vector3d normal)
 {
     Ray reflected = new Ray(
         incoming.Origin,
         Reflect(incoming.Direction, normal));
     return reflected;
 }
开发者ID:bzamecnik,项目名称:bokehlab,代码行数:7,代码来源:Ray.cs

示例6: GetRotateVector

 public static Vector3d GetRotateVector(Vector3d v, double xr, double yr, double zr)
 {
     v = v.TransformBy(Matrix3d.Rotation(xr * System.Math.PI / 180, Vector3d.XAxis, Point3d.Origin));
     v = v.TransformBy(Matrix3d.Rotation(yr * System.Math.PI / 180, Vector3d.YAxis, Point3d.Origin));
     v = v.TransformBy(Matrix3d.Rotation(zr * System.Math.PI / 180, Vector3d.ZAxis, Point3d.Origin));
     return v;
 }
开发者ID:komelio,项目名称:Dimeng.LinkToMicrocad,代码行数:7,代码来源:MathHelper.cs

示例7: Generate

            public override Mesh Generate(Point3d P, Vector3d V)
            {
                Vector3d diffx;
                Vector3d diffy;
                Vector3d diffz = new Vector3d(V);
                double proj;
                diffx = new Vector3d(0, 0, 1);
                proj = System.Math.Abs(Vector3d.Multiply(diffz, diffx));

                if (0.99 < proj && 1.01 > proj) diffx = new Vector3d(1, 0, 0);
                diffy = diffz;
                diffy = Vector3d.CrossProduct(diffy, diffx);
                diffx = Vector3d.CrossProduct(diffy, diffz);
                diffx.Unitize();
                diffy.Unitize();
                diffz.Unitize();

                Mesh M = new Mesh();
                M.Vertices.SetVertex(0, P + diffz * 0.25);
                M.Vertices.SetVertex(1, P + (diffx * 0.7072 + diffy * -.5 + diffz * -.5) * 0.25);
                M.Vertices.SetVertex(2, P + (diffy + diffz * -.5) * 0.25);
                M.Vertices.SetVertex(3, P + (diffx * -0.7072 + diffy * -.5 + diffz * -.5) * 0.25);

                M.Faces.SetFace(0, 0, 1, 2);
                M.Faces.SetFace(1, 0, 2, 3);
                M.Faces.SetFace(2, 0, 3, 1);
                M.Faces.SetFace(3, 3, 2, 1);
                M.FaceNormals.ComputeFaceNormals();
                //M.ComputeVertexNormals();

                return M;
            }
开发者ID:MengdiGuo,项目名称:PachydermAcoustic_Rhinoceros,代码行数:32,代码来源:Classes_Particles.cs

示例8: Point3D

		/// <summary>
		/// Ctor
		/// </summary>
		/// <param name="pos"></param>
		/// <param name="normal"></param>
		/// <param name="color"></param>
		public Point3D(Vector3d pos, Vector3d normal, Color color)
			: this()
		{
			Position = pos;
			Normal = normal;
			Color = color;
		}
开发者ID:robotsrulz,项目名称:Sardauscan,代码行数:13,代码来源:Point3D.cs

示例9: IsHidden

 private static bool IsHidden(Vector3d point)
 {
     Vector3d camera = ScaledSpace.ScaledToLocalSpace(
     PlanetariumCamera.Camera.transform.position);
     foreach (CelestialBody body in hiding_bodies_) {
       Vector3d camera_to_point = point - camera;
       Vector3d camera_to_body = body.position - camera;
       double inner_product = Vector3d.Dot(camera_to_point, camera_to_body);
       double r_squared = body.Radius * body.Radius;
       // The projections on the camera-body axis of |point| and of the horizon
       // have lengths |inner_product| / d and d - r^2/d, where d is the distance
       // between the camera and the body and r is the body's radius, thus if
       // |inner_product| < d^2 - r^2, |point| is above the plane passing
       // through the horizon.
       // Otherwise, we check whether |point| is within the cone hidden from the
       // camera, by comparing the squared cosines multiplied by
       // d^2|camera_to_point|^2.
       // In addition, we check whether we're inside the body (this covers the
       // cap above the horizon plane and below the surface of the body, which
       // would otherwise be displayed).
       double d_squared_minus_r_squared =
       camera_to_body.sqrMagnitude - r_squared;
       if ((body.position - point).sqrMagnitude < r_squared ||
       (inner_product > d_squared_minus_r_squared &&
        inner_product * inner_product >
        camera_to_point.sqrMagnitude * d_squared_minus_r_squared)) {
     return true;
       }
     }
     return false;
 }
开发者ID:pdn4kd,项目名称:Principia,代码行数:31,代码来源:gl_lines.cs

示例10: PolysurfaceEnvironmentComponent

 /// <summary>
 /// Initializes a new instance of the WorldBoxEnvironmentComponent class.
 /// </summary>
 public PolysurfaceEnvironmentComponent()
   : base("Polysurface Environment", "PolysrfEnv",
       "A 3D Polysurface Environment.", RS.icon_polysurfaceEnvironment, "646e7585-d3b0-4ebd-8ce3-8efc5cd6b7d9")
 {
   brep = new Brep();
   borderDir = Vector3d.Zero;
 }
开发者ID:lxfschr,项目名称:Quelea,代码行数:10,代码来源:PolysurfaceEnvironmentComponent.cs

示例11: Do

        /// <summary>
        /// Проводит десериалзиацию
        /// </summary>
        /// <param name="package">Содержимое пакета</param>
        /// <returns>Структура из трех величин</returns>
        public override Vector3d Do(string package)
        {
            string sub = "";
            Vector3d result = new Vector3d();

            int index1 = 0;
            int index2 = package.LastIndexOf('>');

            for (int i = index2 - 1; i >= 0; i--)
            {
                if (package[i] == '<')
                {
                    index1 = i;
                    break;
                }
            }

            if ((index1 != -1) && (index2 != -1) && (index2 >= index1))
                sub = package.Substring(index1 + 1, index2 - index1 - 1);
            else
                throw new ExceptionServer("Block borders are not found");

            string[] parameters = sub.Split(';');

            result.X = double.Parse(parameters[0].Replace(',', '.'), CultureInfo.InvariantCulture); // Pitch
            result.Y = double.Parse(parameters[1].Replace(',', '.'), CultureInfo.InvariantCulture); // Roll
            result.Z = double.Parse(parameters[2].Replace(',', '.'), CultureInfo.InvariantCulture); // Yaw

            return result;
        }
开发者ID:ElderMayday,项目名称:bachelor-server,代码行数:35,代码来源:DeserializerCustom.cs

示例12: Cross

 public static Vector3d Cross(Vector3d lhs, Vector3d rhs)
 {
     return new Vector3d(
         lhs.y * rhs.z - lhs.z * rhs.y,
         lhs.z * rhs.x - lhs.x * rhs.z,
         lhs.x * rhs.y - lhs.y * rhs.x);
 }
开发者ID:Meumeu,项目名称:ProceduralCities,代码行数:7,代码来源:Vector3d.cs

示例13: Compute

        public Vector3d Compute(Vector3d error, Vector3d omega, Vector3d Wlimit)
        {
            derivativeAct = Vector3d.Scale(omega, Kd);
            Wlimit = Vector3d.Scale(Wlimit, Kd);

            // integral actíon + Anti Windup
            intAccum.x = (Math.Abs(derivativeAct.x) < 0.6 * max) ? intAccum.x + (error.x * Ki.x * TimeWarp.fixedDeltaTime) : 0.9 * intAccum.x;
            intAccum.y = (Math.Abs(derivativeAct.y) < 0.6 * max) ? intAccum.y + (error.y * Ki.y * TimeWarp.fixedDeltaTime) : 0.9 * intAccum.y;
            intAccum.z = (Math.Abs(derivativeAct.z) < 0.6 * max) ? intAccum.z + (error.z * Ki.z * TimeWarp.fixedDeltaTime) : 0.9 * intAccum.z;

            propAct = Vector3d.Scale(error, Kp);

            Vector3d action = propAct + intAccum;

            // Clamp (propAct + intAccum) to limit the angular velocity:
            action = new Vector3d(Math.Max(-Wlimit.x, Math.Min(Wlimit.x, action.x)),
                                  Math.Max(-Wlimit.y, Math.Min(Wlimit.y, action.y)),
                                  Math.Max(-Wlimit.z, Math.Min(Wlimit.z, action.z)));

            // add. derivative action
            action += derivativeAct;

            // action clamp
            action = new Vector3d(Math.Max(min, Math.Min(max, action.x)),
                                  Math.Max(min, Math.Min(max, action.y)),
                                  Math.Max(min, Math.Min(max, action.z)));
            return action;
        }
开发者ID:RemoteTechnologiesGroup,项目名称:RemoteTech,代码行数:28,代码来源:PIDControllerV3.cs

示例14: AngleBetweenTwoVectors

 public static double AngleBetweenTwoVectors(Vector3d a, Vector3d b)
 {
     double temp = (a.X * b.X + a.Y * b.Y + a.Z * b.Z) / (a.Length * b.Length);
     if (temp > 1.0) temp = 1.0;
     else if (temp < -1.0) temp = -1.0;
     return Math.Acos(temp);
 }
开发者ID:GeneKao,项目名称:Pavilion2015_ITECH,代码行数:7,代码来源:Utils.cs

示例15: CalculateAcceleration

        /// <summary>
        /// Calculates distance between a hole edge and all other holes. This distance is used to calculate the force between the points and assign an acceleration to a point.
        /// </summary>
        /// <param name="others"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        private void CalculateAcceleration(IList<Hole> others)
        {
            this.newAccelerationVector = Vector3d.Zero;
            double minimumDenominatorToAvoidDivideByZero = 5;
            for (int i = 0; i < others.Count; i++)
            {
                Hole other = others[i];
                Vector3d VectorPointToPointInfluence = other.point - this.point;
                double distanceBetweenPoints = VectorPointToPointInfluence.Length;
                if (distanceBetweenPoints < double.Epsilon)
                {
                    continue;
                }

                double distanceBetweenHoles = distanceBetweenPoints - other.radius - this.radius;
                if (distanceBetweenHoles <= 0) //checks if holes intersect.
                {
                    distanceBetweenHoles = 0;
                }

                VectorPointToPointInfluence.Unitize();
                VectorPointToPointInfluence *= -this.force / (minimumDenominatorToAvoidDivideByZero + distanceBetweenHoles * distanceBetweenHoles);
                VectorPointToPointInfluence = AdjustAccelerationForColourSensitivity(VectorPointToPointInfluence, other);
                this.newAccelerationVector += VectorPointToPointInfluence;
            }

            this.newAccelerationVector = this.ConstrainVectorToMeshFace(this.newAccelerationVector);
        }
开发者ID:formateng,项目名称:repulsive,代码行数:34,代码来源:Holes.cs


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