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


C# Vector3D.DotProduct方法代码示例

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


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

示例1: evaluateTangent

        bool evaluateTangent(InferredCurve inferredCurve, RelatedCurve curve)
        {
            //double angle = Math.Atan((inferredCurve.FromPoint.Y - inferredCurve.ToPoint.Y) / (inferredCurve.FromPoint.X - inferredCurve.ToPoint.X));
            //double length = ((IProximityOperator)inferredCurve.FromPoint).ReturnDistance(inferredCurve.ToPoint);
            
            //the proposed arc chord:
            ILine line = new Line() { FromPoint = inferredCurve.FromPoint, ToPoint = inferredCurve.ToPoint };

            //half the delta of the proposed curve would be:
            double halfdelta = toDegrees(Math.Asin(line.Length / 2 / curve.Radius));

            IVector3D chordVector = new Vector3D() as IVector3D;
            chordVector.PolarSet(line.Angle, 0, 1);

            foreach (RelatedLine tangent in inferredCurve.TangentLines)
            {
                IVector3D tangentVector = new Vector3D() as IVector3D;
                tangentVector.PolarSet(ToRadians(tangent.Angle), 0, 1);

                bool dMatch = false;
                double dVectDiff = toDegrees(Math.Acos(chordVector.DotProduct(tangentVector)));
                if (tangent.Orientation == RelativeOrientation.From_To)
                    dMatch = Math.Abs(dVectDiff - halfdelta) < CurveByInferenceSettings.Instance.MaxTangentLineAngleInDegrees;
                else if (tangent.Orientation == RelativeOrientation.To_From)
                    dMatch = Math.Abs(dVectDiff + halfdelta) < CurveByInferenceSettings.Instance.MaxTangentLineAngleInDegrees;
                else if (tangent.Orientation == RelativeOrientation.From_From)
                    dMatch = Math.Abs(dVectDiff + halfdelta) < CurveByInferenceSettings.Instance.MaxTangentLineAngleInDegrees;
                else if (tangent.Orientation == RelativeOrientation.To_To)
                    dMatch = Math.Abs(dVectDiff - halfdelta) < CurveByInferenceSettings.Instance.MaxTangentLineAngleInDegrees;
                if (dMatch)
                {
                    inferredCurve.InferredRadius = inferredCurve.TangentCurves[0].Radius;
                    inferredCurve.InferredCenterpointID = inferredCurve.TangentCurves[0].CenterpointID;
                    return true;
                }
            }
            return false;
        }
开发者ID:travisval,项目名称:ParcelFabricCurveByInference,代码行数:38,代码来源:CurveByInference.cs

示例2: CalculateColor

        public static Color CalculateColor(Vector3D origin, Vector3D direction, uint depth)
        {
            /*
             * Najpierw sprawdzamy czy promien uderza w kule, jesli nie to musi
             * uderzac w plaszczyzne za kula (ze wzgledu na przyjeta specyfike
             * konstrukcji sceny. Przeciecie z plaszczyzna rowniez nalezy
             * sprawdzic, aby obliczyc kolor i stworzyc "szachownice"
             */
            Color returnColor = Color.FromArgb(0, 0, 0);
            Vector3D intersectionPoint = new Vector3D();
            float distance = float.MaxValue;
            bool inside = false;

            bool sphereHit = raySphereIntersection(origin, direction, out distance, out inside);

            // Jeśli kula nie zostala trafiona
            if (!sphereHit)
            {
                // Sprawdz przeciecie z plaszczyznami
                //float tmpDistance = -1;
                float distRight = -(planeR.d + planeR.vectorNormal.DotProduct(origin)) / (direction.DotProduct(planeR.vectorNormal));
                float distLeft = -(planeL.d + planeL.vectorNormal.DotProduct(origin)) / (direction.DotProduct(planeL.vectorNormal));
                float distDown  = -(planeD.d + planeD.vectorNormal.DotProduct(origin)) / (direction.DotProduct(planeD.vectorNormal));

                float dist = Math.Min(distLeft, distRight);
                dist = distDown > 0 ? Math.Min(distDown, dist) : dist;

                intersectionPoint = origin + direction * dist;

                bool hit = distRight > 0 || distLeft > 0 || distDown > 0;
                if (hit)
                {
                    if (distDown == dist)
                    {
                        returnColor = checkeredTexture(intersectionPoint.x, intersectionPoint.z);
                    }
                    else
                    {
                        returnColor = checkeredTexture(intersectionPoint.x, intersectionPoint.y);
                    }
                }

                return returnColor;
            }

            //if (inside) Console.WriteLine("INSIDE");

            Vector3D vectorObser = new Vector3D();
            Vector3D vectorLight = new Vector3D();
            Vector3D reflectedRay = new Vector3D();
            intersectionPoint = origin + direction * distance;

            // Ponieważ mamy tylko jedno światło nie trzeba robić pętli po wszystkich
            // Wektor od punktu przeciecia do swiatla
            vectorLight.x = (float)light.position.X - intersectionPoint.x;
            vectorLight.y = (float)light.position.Y - intersectionPoint.y;
            vectorLight.z = (float)light.position.Z - intersectionPoint.z;

            float lengthLight = vectorLight.Length();
            vectorLight /= lengthLight;

            // Wektor od punktu przeciecia do obserwatora

            Vector3D vecNorm = intersectionPoint - sphereCenter;
            vecNorm.Normalize();
            vectorObser = origin - intersectionPoint;
            vectorObser.Normalize();

            // Wektor odbicia
            reflectedRay = vecNorm * 2;
            reflectedRay *= vectorObser.DotProduct(vecNorm);
            reflectedRay -= vectorObser;
            reflectedRay.Normalize();

            int red = 0, green = 0, blue = 0;

            // Zalamanie
            if ((material.krcR > 0 || material.krcG > 0 || material.krcB > 0) && depth < maxDepth)
            {
                Vector3D newNorm = new Vector3D(vecNorm);
                Vector3D refractedRey = new Vector3D();
                float n = 0;
                float mult = 1;
                if (!inside)
                {
                    n = 1.0f / material.n;
                }
                else
                {
                    newNorm *= -1;
                    n = material.n / 1.0f;
                }

                float cosI = (newNorm.DotProduct(-direction));
                float cosT2 = 1.0f - n * n * (1.0f - cosI * cosI);

                if (cosT2 > 0)
                {
                    if (cosI > 0)
                        refractedRey = direction * n + newNorm * (n * cosI - (float)Math.Sqrt(cosT2));
//.........这里部分代码省略.........
开发者ID:BGCX261,项目名称:zpi-modeler-svn-to-git,代码行数:101,代码来源:SurfaceRaytracer.cs

示例3: DotProduct

 // Static methods
 public static double DotProduct(Vector3D a, Vector3D b)
 {
     return a.DotProduct(b);
 }
开发者ID:91xie,项目名称:Visual-Studio-2010,代码行数:5,代码来源:Program.cs

示例4: CalculateColor

        public static Color CalculateColor(Vector3D origin, Vector3D direction, uint depth)
        {
            /*
             * Najpierw sprawdzamy czy promien uderza w kule, jesli nie to musi
             * uderzac w plaszczyzne za kula (ze wzgledu na przyjeta specyfike
             * konstrukcji sceny. Przeciecie z plaszczyzna rowniez nalezy
             * sprawdzic, aby obliczyc kolor i stworzyc "szachownice"
             */
            Color returnColor = Color.FromArgb(0, 0, 0);
            Vector3D intersectionPoint = new Vector3D();
            float distance = float.MaxValue;
            int inOut = 0;

            // Sprawdz przecięcie z kulą
            float b = -(origin.DotProduct(direction));
            float delta = (b * b) - (origin.DotProduct(origin)) + sphereRadius*sphereRadius;
            if (delta > 0)
            {
                delta = (float)Math.Sqrt(delta);
                float i1 = b - delta;
                float i2 = b + delta;

                if (i2 > 0)
                {
                    if (i1 < 0)
                    {
                        if (i2 < distance)
                        {
                            // Trafienie z wnętrza kuli
                            distance = i2;
                            inOut = -1;
                        }
                    }
                    else
                    {
                        if (i1 < distance)
                        {
                            // Trafienie od zewnatrz
                            distance = i1;
                            inOut = 1;
                        }
                    }
                }
            }

            // Jeśli kula nie zostala trafiona
            if (distance == float.MaxValue)
            {
                // Sprawdz przeciecie z plaszczyznami (chwilowo tylko plaszczyzna
                // za kula)
                float tmpDistance = -1;
                tmpDistance = -(plane.d + plane.vectorNormal.DotProduct(origin));
                tmpDistance /= plane.vectorNormal.DotProduct(direction);

                if (tmpDistance > -1 && tmpDistance < float.MaxValue)
                {
                    intersectionPoint = origin + direction * tmpDistance;

                    return returnColor = BackgroundColor(intersectionPoint);
                }

                return returnColor;
            }

            Vector3D vectorObser = new Vector3D();
            Vector3D vectorLight = new Vector3D();
            Vector3D reflectedRay = new Vector3D();

            // Intersection point jest jednoczesnie wektorem normlanym trafionej
            // sfery, rowniez znormalizowanym (poniewaz sfera jest o pormieniu 1)
            intersectionPoint = origin + direction * distance;

            // Ponieważ mamy tylko jedno światło nie trzeba robić pętli po wszystkich
            // Wektor od punktu przeciecia do swiatla
            vectorLight.x = (float)light.position.X - intersectionPoint.x;
            vectorLight.y = (float)light.position.Y - intersectionPoint.y;
            vectorLight.z = (float)light.position.Z - intersectionPoint.z;

            float lengthLight = vectorLight.Length();
            vectorLight /= lengthLight;

            // Wektor od punktu przeciecia do obserwatora
            vectorObser = origin - intersectionPoint;
            vectorObser.Normalize();

            // Wektor odbicia
            reflectedRay = intersectionPoint * 2;
            reflectedRay *= vectorObser.DotProduct(intersectionPoint);
            reflectedRay -= vectorObser;
            reflectedRay.Normalize();

            int red = 0, green = 0, blue = 0;

            // Zalamanie
            if ((material.krcR > 0 || material.krcG > 0 || material.krcB > 0) && depth < maxDepth)
            {
                Vector3D refractedRey = new Vector3D();
                Vector3D sphereNormal = new Vector3D();
                float n = 0;
                if (inOut == 1)
//.........这里部分代码省略.........
开发者ID:BGCX261,项目名称:zpi-modeler-svn-to-git,代码行数:101,代码来源:SurfaceRaytracer.cs

示例5: RecalculateD

 public void RecalculateD(Vector3D mpoint)
 {
     D = -mpoint.DotProduct(Normal);
 }
开发者ID:zaki,项目名称:irrlicht.net,代码行数:4,代码来源:Plane3D.cs


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