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


C# Vector.Normalize方法代码示例

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


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

示例1: SetNormalAndPoint

		public void SetNormalAndPoint(Vector normal, Vector point)
		{
			_normal = normal;
			_normal.Normalize();
			_point = point;
			_distance = -_normal.Dot(_point);
		}
开发者ID:baldercollaborator,项目名称:Balder,代码行数:7,代码来源:Plane.cs

示例2: Wolfe

        /// <summary>
        /// Computes the maximum descent possible from the vector x in the direction dir.
        /// </summary>
        /// <param name="func">Function to find it the greatest descent possible in the given direction.</param>
        /// <param name="x">Current vector of the minimization Quasi-Newton algorithm.</param>
        /// <param name="dir">Descent direction vector for the current vector.</param>
        /// <returns>The value of the maximum descent possible.</returns>
        public static double Wolfe(CompiledFunc func, Vector x, Vector dir)
        {
            double a = 0;
            double ai = 1;
            double fPrev = 0, fCurr = 0, diff = 0;

            double fZero = func.Eval(x);
            var normDir = dir.Normalize();

            double diffZero = (func.Differentiate(x)*normDir).Sum();

            while(ai < MaxAlpha)
            {
                fPrev = func.Eval(x + a*dir);
                fCurr = func.Eval(x + ai*dir);

                if (fCurr > fZero + C1*ai*diffZero || (fCurr > fPrev && ai > 1))
                    return Zoom(func, x, dir, a, ai, fZero, diffZero);

                diff = (func.Differentiate(x + ai*dir)*normDir).Sum();

                if (Math.Abs(diff) <= -C2*diffZero)
                    return ai;

                if (diff >= 0)
                    return Zoom(func, x, dir, ai, a, fZero, diffZero);

                a = ai;
                ai *= 1.5;
            }

            return ai;
        }
开发者ID:renehernandez,项目名称:SharpOptimization,代码行数:40,代码来源:LinearSearch.cs

示例3: SkyLight

 public SkyLight(float turb, Vector sd)
 {
     this.turbidity = turb;
     this.sundir = sd.Normalize();
     this.gain = new RgbSpectrum(1f);
     this.Init();
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:SkyLight.cs

示例4: Zoom

        private static double Zoom(CompiledFunc func, Vector x, Vector dir, double aLow, double aHigh, double fZero, double diffZero)
        {
            var normDir = dir.Normalize();
            double aMid = 0;
            double fValue = 0;
            double diff = 0;

            while (Math.Abs(aLow - aHigh) > EPS)
            {
                aMid = aLow + (aHigh - aLow)/2;
                fValue = func.Eval(x + aMid*dir);

                if (fValue > fZero + C1*aMid*diffZero || fValue >= func.Eval(x + aLow*dir))
                    aHigh = aMid;
                else
                {
                    diff = (func.Differentiate(x + aMid*dir)*normDir).Sum();

                    if (Math.Abs(diff) <= -C2*diffZero)
                        return aMid;

                    if (diff*(aHigh - aLow) >= 0)
                        aHigh = aLow;

                    aLow = aMid;
                }
            }

            return aMid;
        }
开发者ID:renehernandez,项目名称:SharpOptimization,代码行数:30,代码来源:LinearSearch.cs

示例5: TestNormalize

        public void TestNormalize()
        {
            Vector v1 = new Vector( 3.0f, 1.0f, 2.0f );
            Vector v2 = new Vector( 0.8017837f, 0.2672612f, 0.5345225f );

            Assert.AreEqual( v2, v1.Normalize() );
        }
开发者ID:BradleyMarie,项目名称:IrisSharp,代码行数:7,代码来源:VectorTest.cs

示例6: NormalizeVector

        public void NormalizeVector()
        {
            var v1 = new Vector(1,2,3);

            var normVector = v1.Normalize();

            Assert.AreEqual(1.0, Algebra.Norm(normVector), 1e-8);
        }
开发者ID:renehernandez,项目名称:SharpOptimization,代码行数:8,代码来源:VectorTest.cs

示例7: Light

 public Light(Vector direction, uint diffuse, uint specular, int highlightSheen, int highlightSpread)
 {
     v=direction.Clone();
     v.Normalize();
     this.diffuse=diffuse;
     this.specular=specular;
     this.highlightSheen=highlightSheen;
     this.highlightSpread=highlightSpread;
 }
开发者ID:tgjones,项目名称:idx3dsharp,代码行数:9,代码来源:Light.cs

示例8: CosineSimilarity

        public double CosineSimilarity(Vector v1, Vector v2, double norm)
        {
            v1.Normalize(p: norm);
            v2.Normalize(p: norm);
            double l1 = Math.Sqrt(v1 * v1);
            double l2 = Math.Sqrt(v2 * v2);
            double similarity = (v1 * v2) / (l1 * l2);

            return similarity;
        }
开发者ID:nikdon,项目名称:SimilarityMeasure,代码行数:10,代码来源:SimCalc.cs

示例9: CalculateNormal

	/**
	 * CalculateNormal
	 */
	private void CalculateNormal()
	{
		Vector ba = new Vector();
		Vector bc = new Vector();

		Normal = new Vector();
		ba.Sub(Vertices[0], Vertices[1]);
		bc.Sub(Vertices[2], Vertices[1]);
		Normal.Cross(bc, ba);
		Normal.Normalize();
	}
开发者ID:lewurm,项目名称:benchmarker,代码行数:14,代码来源:PolyTypeObj.cs

示例10: SetVectors

		public void SetVectors(Vector vector1, Vector vector2, Vector vector3)
		{
			_vector1 = vector1;
			_vector2 = vector2;
			_vector3 = vector3;

			var aux1 = vector1 - vector2;
			var aux2 = vector3 - vector2;

			_normal = aux2 * aux1;
			_normal.Normalize();
			_point = vector2;
			_distance = -_normal.Dot(_point);
		}
开发者ID:baldercollaborator,项目名称:Balder,代码行数:14,代码来源:Plane.cs

示例11: Update

        public void Update()
        {
            dir = (Target - (Vector)Position);
            dir = dir.Normalize();

            Vector up = Up;

            float k = MathLab.Radians(fieldOfView);
            x = (dir ^ up);
            x.Normalize();
            x *= Width * k / Height;

            y = (dir ^ x);
            y.Normalize();
            y *= k;
            this.CreateProjectionMatrix();
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:17,代码来源:FiniteAppertureCamera.cs

示例12: EyeRays

    /// <summary>
    /// Construct eye-rays through the specified pixels
    /// </summary>
    /// <param name="icp">Intrinsic camera parameters</param>
    /// <param name="pixels">Pixels</param>
    /// <returns>Enumerable ray collection</returns>
    public static Ray[] EyeRays(Emgu.CV.IntrinsicCameraParameters icp, PointF[] pixels) {
      Ray[] rays = new Ray[pixels.Length];
      if (pixels.Length > 0) {
        // 1. Undistort pixels
        PointF[] undistorted_pixels = icp.Undistort(pixels, null, icp.IntrinsicMatrix);
        // 2. Create rays
        // Use inverse intrinsic calibration and depth = 1
        double cx = icp.IntrinsicMatrix.Data[0, 2];
        double cy = icp.IntrinsicMatrix.Data[1, 2];
        double fx = icp.IntrinsicMatrix.Data[0, 0];
        double fy = icp.IntrinsicMatrix.Data[1, 1];


        Vector direction = new Vector(3);
        for (int i = 0; i < undistorted_pixels.Length; ++i) {
          PointF pixel = undistorted_pixels[i];
          direction[0] = (pixel.X - cx) / fx;
          direction[1] = (pixel.Y - cy) / fy;
          direction[2] = 1;
          rays[i] = new Ray(direction.Normalize());
        }
      }
      return rays;
    }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:30,代码来源:Ray.cs

示例13: Translate

        /// <summary>
        /// Translates the coordinate system in the direction of the vector and by the distance specified
        /// </summary>
        /// <param name="translationVector">The direction of translation</param>
        /// <param name="distance">The distance of translation</param>
        /// <returns></returns>
        public CoordinateSystem Translate(Vector translationVector, double distance)
        {
            if (translationVector == null)
            {
                throw new System.ArgumentNullException("translationVector");
            }
            translationVector = translationVector.Normalize().MultiplyBy(distance);
            var translatedCSEntity = CSEntity.Translate(translationVector.IVector);
            var cs = new CoordinateSystem(translatedCSEntity, true);

            return cs;
        }
开发者ID:samuto,项目名称:designscript,代码行数:18,代码来源:CoordinateSystem.cs

示例14: ByCenterPointRadiusCore

        private static ICircleEntity ByCenterPointRadiusCore(Point centerPoint, double radius, ref Vector normal)
        {
            if (null == centerPoint)
                throw new ArgumentNullException("centerPoint");
            if (null == normal)
                throw new ArgumentNullException("normal");
            if (normal.IsZeroVector())
                throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal"), "normal");
            if (radius <= 0.0)
                throw new ArgumentException(Properties.Resources.IsZeroRadius);

            normal = normal.IsNormalized ? normal : normal.Normalize();
            ICircleEntity entity = HostFactory.Factory.CircleByCenterPointRadius(centerPoint.PointEntity, radius, normal.IVector);
            if (null == entity)
                throw new Exception(string.Format(Properties.Resources.OperationFailed, "Circle.ByCenterPointRadius"));
            return entity;
        }
开发者ID:samuto,项目名称:designscript,代码行数:17,代码来源:Circle.cs

示例15: Run

        public override bool Run()
        {
            bool Result = false;
            double deltaBB_side = 0.0;

            try
            {
                FittingGap = _data.P1;
                //Get primary and secondary
                Beam PrimaryBeam = _Model.SelectModelObject(Primary) as Beam;
                Beam SecondaryBeam = _Model.SelectModelObject(Secondaries[0]) as Beam;
                if (PrimaryBeam != null && SecondaryBeam != null)
                {
                    TransformationPlane originalTransformationPlane = _Model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                    CoordinateSystem coordSys = PrimaryBeam.GetCoordinateSystem();

                    Matrix ToThisPlane = _Model.GetWorkPlaneHandler().GetCurrentTransformationPlane().TransformationMatrixToGlobal;

                    //Translaatiot molemmille pisteille
                    Point joint_point1 = ToThisPlane.Transform(new Point(0, 0, 0));
                    Point joint_point2 = ToThisPlane.Transform(new Point(1, 0, 0));
                    Vector joint_vector = new Vector(joint_point2 - joint_point1);
                    joint_vector.Normalize();

                    if (_Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(coordSys)))
                    {
                        Matrix ToThisPlane2 = _Model.GetWorkPlaneHandler().GetCurrentTransformationPlane().TransformationMatrixToGlobal;
                        //Translaatiot molemmille pisteille
                        Point primpart_point1 = ToThisPlane2.Transform(new Point(0, 0, 0));
                        Point primpart_point2 = ToThisPlane2.Transform(new Point(0, 0, 1));
                        Vector primpart_vector = new Vector(primpart_point2 - primpart_point1);
                        primpart_vector.Normalize();

                        string ProfileSubtype = "";

                        if (PrimaryBeam.GetReportProperty("PROFILE.SUBTYPE", ref ProfileSubtype))
                            if (ProfileSubtype == "ABEAM")
                            {
                                double ABEAM_c1 = 0.0;
                                double ABEAM_c3 = 0.0;
                                PrimaryBeam.GetReportProperty("PROFILE.c1", ref ABEAM_c1);
                                PrimaryBeam.GetReportProperty("PROFILE.c3", ref ABEAM_c3);
                                deltaBB_side = ABEAM_c3 - ABEAM_c1;
                            }
                            else
                            {
                                if (joint_vector.X * primpart_vector.X > 0)
                                    // hae deltapalkin right-parametrit
                                    PrimaryBeam.GetReportProperty("PROFILE.bb.right", ref deltaBB_side);
                                else if (joint_vector.Y * primpart_vector.Y > 0)
                                    // hae deltapalkin right-parametrit
                                    PrimaryBeam.GetReportProperty("PROFILE.bb.right", ref deltaBB_side);
                                else
                                    // hae deltapalkin left-parametrit
                                    PrimaryBeam.GetReportProperty("PROFILE.bb.left", ref deltaBB_side);
                            }
                        _Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(originalTransformationPlane);
                    }
                    // siirrä yz-tasoa x-suunnassa
                    // luo fitting liitoksen yz-tasossa
                    CreateFittings(SecondaryBeam, deltaBB_side + FittingGap);
                    Result = true;
                }
            }

            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }

            return Result;
        }
开发者ID:jorhop,项目名称:TS_conn_HollowCoreSlabFitting,代码行数:72,代码来源:HollowCoreSlabFitting.cs


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