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


C# Vector3D.Abs方法代码示例

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


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

示例1: Offset

 /// <summary>
 /// Offsets a vector by a hyperbolic distance.
 /// </summary>
 public static Vector3D Offset( Vector3D v, double hDist )
 {
     double mag = v.Abs();
     mag = DonHatch.h2eNorm( DonHatch.e2hNorm( mag ) + hDist );
     v.Normalize();
     v *= mag;
     return v;
 }
开发者ID:roice3,项目名称:Honeycombs,代码行数:11,代码来源:Hyperbolic2D.cs

示例2: DistancePointPlane

        public static double DistancePointPlane( Vector3D normalVector, Vector3D planePoint, Vector3D point )
        {
            // Check to make sure that plane is not degenerate.
            if( Tolerance.Zero( normalVector.MagSquared() ) )
                return double.NaN;

            // Here is the distance (signed depending on which side of the plane we are on).
            return ( point - planePoint ).Dot( normalVector ) / normalVector.Abs();
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:9,代码来源:Euclidean3D.cs

示例3: DistancePointLine

        public static double DistancePointLine( Vector3D n1, Vector3D p1, Vector3D point )
        {
            // Check to make sure that n1 is not degenerate.
            if( Tolerance.Zero( n1.MagSquared() ) )
                return double.NaN;

            // ZZZ - Can we make this a signed distance?
            return ( ( point - p1 ).Cross( n1 ) ).Abs() / n1.Abs();
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:9,代码来源:Euclidean3D.cs

示例4: IsInfinite

 public static bool IsInfinite( Vector3D input )
 {
     // XXX - ugly hack I'd like to improve.
     return
         IsInfinite( input.X ) ||
         IsInfinite( input.Y ) ||
         IsInfinite( input.Z ) ||
         IsInfinite( input.W ) ||
         input.Abs() > InfiniteScale;
 }
开发者ID:roice3,项目名称:Honeycombs,代码行数:10,代码来源:Infinity.cs

示例5: SinAngle

 /// <summary>
 /// Calculate the sine of the angle between two vectors.
 /// </summary>
 private static double SinAngle( Vector3D p1, Vector3D p2 )
 {
     double sinA = (p1.Cross( p2 )).Abs() / (p1.Abs() * p2.Abs());
     return Clamp( sinA );
 }
开发者ID:roice3,项目名称:Honeycombs,代码行数:8,代码来源:SphericalTrig.cs

示例6: CosAngle

 /// <summary>
 /// Calculate the cosine of the angle between two vectors.
 /// </summary>
 private static double CosAngle( Vector3D p1, Vector3D p2 )
 {
     double cosA = p1.Dot( p2 ) / (p1.Abs() * p2.Abs());
     return Clamp( cosA );
 }
开发者ID:roice3,项目名称:Honeycombs,代码行数:8,代码来源:SphericalTrig.cs

示例7: OrthogonalSphereInterior

            /// <summary>
            /// Find an orthogonal sphere defined by a single interior point.
            /// This point is the unique point on the sphere that is furthest from the ball boundary.
            /// (equivalently, closest to the origin)
            /// </summary>
            public static Sphere OrthogonalSphereInterior( Vector3D v )
            {
                // r = radius of sphere
                // c = distance from origin to passed in point
                // http://www.wolframalpha.com/input/?i=%28c%2Br%29%5E2+%3D+1+%2B+r%5E2%2C+solve+for+r
                double c = v.Abs();
                double r = -(c * c - 1) / (2 * c);

                v.Normalize();
                return new Sphere()
                {
                    Center = v * ( c + r ),
                    Radius = r
                };
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:20,代码来源:H3Utils.cs

示例8: HalfTo

 private static Vector3D HalfTo( Vector3D v )
 {
     double distHyperbolic = DonHatch.e2hNorm( v.Abs() );
     double halfDistEuclidean = DonHatch.h2eNorm( distHyperbolic / 3 );
     Vector3D result = v;
     result.Normalize( halfDistEuclidean );
     return result;
 }
开发者ID:roice3,项目名称:Honeycombs,代码行数:8,代码来源:H3Utils.cs

示例9: LOD_Finite

            /// <summary>
            /// LOD
            /// </summary>
            public static void LOD_Finite( Vector3D e1, Vector3D e2, out int div1, out int div2, H3.Settings settings )
            {
                //if( settings.Halfspace )
                //	throw new System.NotImplementedException();

                int maxHit = 15;
                int hit = (int)( Math.Max( e1.Abs(), e2.Abs() ) * maxHit );
                div1 = 11;
                div2 = 30 - hit;

                /* lasercrystal
                int maxHit = 8;
                int hit = (int)( Math.Max( e1.Abs(), e2.Abs() ) * maxHit );
                div1 = 6;
                div2 = 20 - hit;*/
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:19,代码来源:H3Utils.cs

示例10: OrthogonalCircleInterior

            /// <summary>
            /// Given 2 points in the interior of the ball, calculate the center and radius of the orthogonal circle.
            /// One point may optionally be on the boundary, but one shoudl be in the interior.
            /// If both points are on the boundary, we'll fall back on our other method.
            /// </summary>
            public static void OrthogonalCircleInterior( Vector3D v1, Vector3D v2, out Circle3D circle )
            {
                if( Tolerance.Equal( v1.Abs(), 1 ) &&
                    Tolerance.Equal( v2.Abs(), 1 ) )
                {
                    circle = OrthogonalCircle( v1, v2 );
                    return;
                }

                // http://www.math.washington.edu/~king/coursedir/m445w06/ortho/01-07-ortho-to3.html
                // http://www.youtube.com/watch?v=Bkvo09KE1zo

                Vector3D interior = Tolerance.Equal( v1.Abs(), 1 ) ? v2 : v1;

                Sphere ball = new Sphere();
                Vector3D reflected = ball.ReflectPoint( interior );
                circle = new Circle3D( reflected, v1, v2 );
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:23,代码来源:H3Utils.cs

示例11: GeodesicPoints

            /// <summary>
            /// Calculate points along a geodesic segment from v1 to v2.
            /// </summary>
            public static Vector3D[] GeodesicPoints( Vector3D v1, Vector3D v2, int div )
            {
                Vector3D center, normal;
                double radius, angleTot;
                Geodesic( v1, v2, out center, out radius, out normal, out angleTot );

                if( Infinity.IsInfinite( radius ) ||
                    Tolerance.Zero( v1.Abs() ) || Tolerance.Zero( v2.Abs() ) )	// HACK! radius should be infinite, something wrong with geodesic func
                {
                    Segment seg = Segment.Line( v1, v2 );
                    return seg.Subdivide( div );
                    //return new Vector3D[] { v1, v2 };
                }
                else
                    return Shapeways.CalcArcPoints( center, radius, v1, normal, angleTot, div );
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:19,代码来源:H3Utils.cs

示例12: DupinCyclideSphere

            /// <summary>
            /// Helper that works in all geometries.
            /// center: http://www.wolframalpha.com/input/?i=%28+%28+%28+r+%2B+p+%29+%2F+%28+1+-+r*p+%29+%29+%2B+%28+%28+-r+%2B+p+%29+%2F+%28+1+%2B+r*p+%29+%29++%29+%2F+2
            /// radius: http://www.wolframalpha.com/input/?i=%28+%28+%28+r+%2B+p+%29+%2F+%28+1+-+r*p+%29+%29+-+%28+%28+-r+%2B+p+%29+%2F+%28+1+%2B+r*p+%29+%29++%29+%2F+2
            /// </summary>
            public static void DupinCyclideSphere( Vector3D vNonEuclidean, double radiusEuclideanOrigin, Geometry g,
				out Vector3D centerEuclidean, out double radiusEuclidean )
            {
                if( g == Geometry.Euclidean )
                {
                    centerEuclidean = vNonEuclidean;
                    radiusEuclidean = radiusEuclideanOrigin;
                    return;
                }

                double p = vNonEuclidean.Abs();
                if( !vNonEuclidean.Normalize() )
                {
                    // We are at the origin.
                    centerEuclidean = vNonEuclidean;
                    radiusEuclidean = radiusEuclideanOrigin;
                    return;
                }

                double r = radiusEuclideanOrigin;
                double numeratorCenter = g == Geometry.Hyperbolic ? ( 1 - r * r ) : ( 1 + r * r );
                double numeratorRadius = g == Geometry.Hyperbolic ? ( 1 - p * p ) : ( 1 + p * p );

                double center = p * numeratorCenter / ( 1 - p * p * r * r );
                radiusEuclidean = r * numeratorRadius / ( 1 - p * p * r * r );
                centerEuclidean = vNonEuclidean * center;

                /*
                // Alternate impl, in this case for spherical.
                Mobius m = new Mobius();
                m.Isometry( Geometry.Spherical, 0, p1 );
                Vector3D t1 = m.Apply( new Vector3D( mag, 0, 0 ) );
                Vector3D t2 = m.Apply( new Vector3D( -mag, 0, 0 ) );
                center = ( t1 + t2 ) / 2;
                radius = t1.Dist( t2 ) / 2; */
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:41,代码来源:H3Utils.cs

示例13: SphericalToCartesian

        // r,theta,phi -> x,y,z
        public static Vector3D SphericalToCartesian( Vector3D v )
        {
            if( Tolerance.Zero( v.Abs() ) )
                return new Vector3D();

            return new Vector3D(
                v.X * Math.Sin( v.Y ) * Math.Cos( v.Z ),
                v.X * Math.Sin( v.Y ) * Math.Sin( v.Z ),
                v.X * Math.Cos( v.Y ) );
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:11,代码来源:H3Utils.cs

示例14: CartesianToSpherical

        // x,y,z -> r,theta,phi
        public static Vector3D CartesianToSpherical( Vector3D v )
        {
            double r = v.Abs();
            if( Tolerance.Zero( r ) )
                return new Vector3D();

            return new Vector3D(
                r,
                Math.Acos( v.Z / r ),
                Math.Atan2( v.Y, v.X ) );
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:12,代码来源:H3Utils.cs

示例15: GeodesicIdealEndpoints

            /// <summary>
            /// Given two points (in the UHS model), find the endpoints 
            /// of the associated geodesic that lie on the z=0 plane.
            /// </summary>
            public static void GeodesicIdealEndpoints( Vector3D v1, Vector3D v2, out Vector3D z1, out Vector3D z2 )
            {
                // We have to special case when geodesic is vertical (parallel to z axis).
                Vector3D diff = v2 - v1;
                Vector3D diffFlat = new Vector3D( diff.X, diff.Y );
                if( Tolerance.Zero( diffFlat.Abs() ) )	// Vertical
                {
                    Vector3D basePoint = new Vector3D( v1.X, v1.Y );
                    z1 = diff.Z > 0 ? basePoint : Infinity.InfinityVector;
                    z2 = diff.Z < 0 ? basePoint : Infinity.InfinityVector;
                }
                else
                {
                    if( Tolerance.Zero( v1.Z ) && Tolerance.Zero( v2.Z ) )
                    {
                        z1 = v1;
                        z2 = v2;
                        return;
                    }

                    // If one point is ideal, we need to not reflect that one!
                    bool swapped = false;
                    if( Tolerance.Zero( v1.Z ) )
                    {
                        Utils.SwapPoints( ref v1, ref v2 );
                        swapped = true;
                    }

                    Vector3D v1_reflected = v1;
                    v1_reflected.Z *= -1;
                    Circle3D c = new Circle3D( v1_reflected, v1, v2 );
                    Vector3D radial = v1 - c.Center;
                    radial.Z = 0;
                    if( !radial.Normalize() )
                    {
                        radial = v2 - c.Center;
                        radial.Z = 0;
                        if( !radial.Normalize() )
                            System.Diagnostics.Debugger.Break();
                    }

                    radial *= c.Radius;
                    z1 = c.Center + radial;
                    z2 = c.Center - radial;

                    // Make sure the order will be right.
                    // (z1 closest to v1 along arc).
                    if( v1.Dist( z1 ) > v2.Dist( z1 ) )
                        Utils.SwapPoints( ref z1, ref z2 );
                    if( swapped )
                        Utils.SwapPoints( ref z1, ref z2 );
                }
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:57,代码来源:H3Utils.cs


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