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


C# Vector3D.RotateAboutAxis方法代码示例

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


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

示例1: IntersectionCircleCircle

        /// <summary>
        /// NOTE: Not general, and assumes some things we know about this problem domain, 
        /// e.g. that c1 and c2 live on the same sphere of radius 1, and have two intersection points.
        /// </summary>
        public static void IntersectionCircleCircle( Vector3D sphereCenter, Circle3D c1, Circle3D c2, out Vector3D i1, out Vector3D i2 )
        {
            // Spherical analogue of our flat circle-circle intersection.
            // Spherical pythagorean theorem for sphere where r=1: cos(hypt) = cos(A)*cos(B)

            Circle3D clone1 = c1.Clone(), clone2 = c2.Clone();
            //clone1.Center -= sphereCenter;
            //clone2.Center -= sphereCenter;

            // Great circle (denoted by normal vector), and distance between the centers.
            Vector3D gc = clone2.Normal.Cross( clone1.Normal );
            double d = clone2.Normal.AngleTo( clone1.Normal );
            double r1 = clone1.Normal.AngleTo( clone1.PointOnCircle );
            double r2 = clone2.Normal.AngleTo( clone2.PointOnCircle );

            // Calculate distances we need.  So ugly!
            // http://www.wolframalpha.com/input/?i=cos%28r1%29%2Fcos%28r2%29+%3D+cos%28x%29%2Fcos%28d-x%29%2C+solve+for+x
            double t1 = Math.Pow( Math.Tan( d / 2 ), 2 );
            double t2 = Math.Cos( r1 ) / Math.Cos( r2 );
            double t3 = Math.Sqrt( (t1 + 1) * (t1 * t2 * t2 + 2 * t1 * t2 + t1 + t2 * t2 - 2 * t2 + 1) ) - 2 * t1 * t2;
            double x = 2 * Math.Atan( t3 / (t1 * t2 + t1 - t2 + 1) );
            double y = Math.Acos( Math.Cos( r1 ) / Math.Cos( x ) );

            i1 = clone1.Normal;
            i1.RotateAboutAxis( gc, x );
            i2 = i1;

            // Perpendicular to gc through i1.
            Vector3D gc2 = i1.Cross( gc );
            i1.RotateAboutAxis( gc2, y );
            i2.RotateAboutAxis( gc2, -y );
            i1 += sphereCenter;
            i2 += sphereCenter;

            /*
            // It would be nice to do the spherical analogue of circle-circle intersections, like here:
            // http://mathworld.wolfram.com/Circle-CircleIntersection.html
            // But I don't want to jump down that rabbit hole and am going to sacrifice some speed to use
            // my existing euclidean function.

            // Stereographic projection to the plane.  XXX - Crap, circles may become lines, and this isn't being handled well.
            Circle3D c1Plane = H3Models.BallToUHS( clone1 );
            Circle3D c2Plane = H3Models.BallToUHS( clone2 );
            if( 2 != Euclidean2D.IntersectionCircleCircle( c1Plane.ToFlatCircle(), c2Plane.ToFlatCircle(), out i1, out i2 ) )
                throw new System.Exception( "Expected two intersection points" );
            i1 = H3Models.UHSToBall( i1 ); i1 += sphereCenter;
            i2 = H3Models.UHSToBall( i2 ); i2 += sphereCenter;
            */
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:53,代码来源:SphericalTrig.cs

示例2: Transform

        public Vector3D Transform( Vector3D v )
        {
            v.RotateAboutAxis( new Vector3D( 1, 0 ), Math.PI / 2 );

            Mobius m = new Mobius();
            m.Isometry( Geometry.Hyperbolic, 0, new Complex( 0, 0.6 ) );
            v = H3Models.TransformHelper( v, m );

            v.RotateAboutAxis( new Vector3D( 1, 0 ), -Math.PI / 2 );
            return v;
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:11,代码来源:H3Ruled.cs

示例3: AddArc

        public void AddArc( Vector3D center, double arcRadius, Vector3D v1, Vector3D normal, double angleTot, int numPoints, System.Func<Vector3D, double> sizeFunc )
        {
            if( numPoints < 2 )
                numPoints = 2;

            Vector3D[] points = CalcArcPoints( center, arcRadius, v1, normal, angleTot, numPoints );

            // Calculate all the disks.
            // XXX - duplicated code with CalcDisks, but we need to calc our own perpendicular here.
            List<Vector3D[]> disks = new List<Vector3D[]>();
            for( int i=0; i<points.Length; i++ )
            {
                Vector3D p1 = i == 0 ? points[0] : points[i - 1];
                Vector3D p2 = points[i];
                Vector3D p3 = i == points.Length - 1 ? points[points.Length - 1] : points[i + 1];
                double radius = sizeFunc( points[i] );

                // We can calculate these directly.
                Vector3D perp = p2 - center;
                perp.Normalize();
                Vector3D axis = perp;
                axis.RotateAboutAxis( normal, -Math.PI / 2 );
                perp *= radius;

                disks.Add( Disk( p2, axis, perp, this.Div, reverse: false ) );
            }

            ///////////////////////////////////////// Hack to avoid having to put spheres at verts.
            double thickness = 0.0055;	// relates to SizeFuncConst
            double thetaOffset = thickness / arcRadius;
            Vector3D start = points[0], end = points[points.Length-1];
            start -= center;
            end -= center;
            start.RotateAboutAxis( normal, -thetaOffset );
            end.RotateAboutAxis( normal, thetaOffset );
            start += center;
            end += center;
            points[0] = start;
            points[points.Length - 1] = end;
            /////////////////////////////////////////

            AddCurve( disks, points, points.First(), points.Last() );
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:43,代码来源:Shapeways.cs

示例4: IdealPoints

            /// <summary>
            /// Given a geodesic sphere, calculates 3 ideal points of the sphere.
            /// NOTE: s1 and s2 will be antipodal on the ideal circle.
            /// </summary>
            public static void IdealPoints( Sphere s, out Vector3D s1, out Vector3D s2, out Vector3D s3 )
            {
                // Get two points on the ball and sphere.
                // http://mathworld.wolfram.com/OrthogonalCircles.html
                // Orthogonal circles, plus some right angle stuff...
                double r = s.Radius;
                Vector3D direction = s.Center;
                Vector3D perp = direction.Perpendicular();
                direction.Normalize();
                s1 = direction;
                s2 = direction;

                double alpha = Math.Atan( r );
                s1.RotateAboutAxis( perp, alpha );
                s2.RotateAboutAxis( perp, -alpha );
                s3 = s1;
                s3.RotateAboutAxis( direction, Math.PI / 2 );
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:22,代码来源:H3Utils.cs


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