本文整理汇总了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 );
}
示例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;
}