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


C# Vector3D.AngleTo方法代码示例

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


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

示例1: OrthogonalCircle

            /// <summary>
            /// Given 2 points on the surface of the ball, calculate the center and radius of the orthogonal circle.
            /// </summary>
            public static void OrthogonalCircle( Vector3D v1, Vector3D v2, out Vector3D center, out double radius )
            {
                // Picture at http://planetmath.org/OrthogonalCircles.html helpful for what I'm doing here.
                double sectorAngle = v1.AngleTo( v2 );
                if( Tolerance.Equal( sectorAngle, Math.PI ) )
                {
                    center = Infinity.InfinityVector;
                    radius = double.PositiveInfinity;
                    return;
                }

                double distToCenter = m_pRadius / Math.Cos( sectorAngle / 2 );
                center = v1 + v2;
                center.Normalize();
                center *= distToCenter;

                radius = distToCenter * Math.Sin( sectorAngle / 2 );
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:21,代码来源:H3Utils.cs

示例2: Midpoint

            /// <summary>
            /// Calculate the hyperbolic midpoint of an edge.
            /// Only works for non-ideal edges at the moment.
            /// </summary>
            public static Vector3D Midpoint( H3.Cell.Edge edge )
            {
                // Special case if edge has endpoint on origin.
                // XXX - Really this should be special case anytime edge goes through origin.
                Vector3D e1 = edge.Start;
                Vector3D e2 = edge.End;
                if( e1.IsOrigin || e2.IsOrigin )
                {
                    if( e2.IsOrigin )
                        Utils.Swap<Vector3D>( ref e1, ref e2 );

                    return HalfTo( e2 );
                }

                // No doubt there is a much better way, but
                // work in H2 slice transformed to xy plane, with e1 on x-axis.

                double angle = e1.AngleTo( e2 );	// always <= 180
                e1 = new Vector3D( e1.Abs(), 0 );
                e2 = new Vector3D( e2.Abs(), 0 );
                e2.RotateXY( angle );

                // Mobius that will move e1 to origin.
                Mobius m = new Mobius();
                m.Isometry( Geometry.Hyperbolic, 0, -e1 );
                e2 = m.Apply( e2 );

                Vector3D midOnPlane = HalfTo( e2 );
                midOnPlane= m.Inverse().Apply( midOnPlane );
                double midAngle = e1.AngleTo( midOnPlane );

                Vector3D mid = edge.Start;
                mid.RotateAboutAxis( edge.Start.Cross( edge.End ), midAngle );
                mid.Normalize( midOnPlane.Abs() );
                return mid;
            }
开发者ID:roice3,项目名称:Honeycombs,代码行数:40,代码来源:H3Utils.cs


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