本文整理汇总了C#中Vector3D.RotateXY方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3D.RotateXY方法的具体用法?C# Vector3D.RotateXY怎么用?C# Vector3D.RotateXY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3D
的用法示例。
在下文中一共展示了Vector3D.RotateXY方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Helicoid
public H3.Cell.Edge[] Helicoid()
{
List<H3.Cell.Edge> fiberList = new List<H3.Cell.Edge>();
double rotationRate = Math.PI / 40;
int numFibers = 350;
// Note: we need to increment a constant hyperbolic distance each step.
int count = 0;
double max = DonHatch.e2hNorm( 0.99 );
double offset = max * 2 / (numFibers - 1);
for( double z_h = -max; z_h <= max; z_h += offset )
{
double z = DonHatch.h2eNorm( z_h );
Sphere s = H3Models.Ball.OrthogonalSphereInterior( new Vector3D( 0, 0, z ) );
Circle3D c = H3Models.Ball.IdealCircle( s );
// Two endpoints of our fiber.
Vector3D v1 = new Vector3D( c.Radius, 0, c.Center.Z );
Vector3D v2 = new Vector3D( -c.Radius, 0, c.Center.Z );
v1.RotateXY( rotationRate * count );
v2.RotateXY( rotationRate * count );
v1 = Transform( v1 );
v2 = Transform( v2 );
fiberList.Add( new H3.Cell.Edge( v1, v2 ) );
count++;
}
return fiberList.ToArray();
}
示例2: IntersectionCircleCircle
public static int IntersectionCircleCircle( Circle c1, Circle c2, out Vector3D p1, out Vector3D p2 )
{
p1 = new Vector3D();
p2 = new Vector3D();
// A useful page describing the cases in this function is:
// http://ozviz.wasp.uwa.edu.au/~pbourke/geometry/2circle/
// Maybe here now? http://paulbourke.net/geometry/circlesphere/
// Vector and distance between the centers.
Vector3D v = c2.Center - c1.Center;
double d = v.Abs();
double r1 = c1.Radius;
double r2 = c2.Radius;
// Circle centers coincident.
if( Tolerance.Zero( d ) )
{
if( Tolerance.Equal( r1, r2 ) )
return -1;
else
return 0;
}
// We should be able to normalize at this point.
if( !v.Normalize() )
{
Debug.Assert( false );
return 0;
}
// No intersection points.
// First case is disjoint circles.
// Second case is where one circle contains the other.
if( Tolerance.GreaterThan( d, r1 + r2 ) ||
Tolerance.LessThan( d, Math.Abs( r1 - r2 ) ) )
return 0;
// One intersection point.
if( Tolerance.Equal( d, r1 + r2 ) ||
Tolerance.Equal( d, Math.Abs( r1 - r2 ) ) )
{
p1 = c1.Center + v * r1;
return 1;
}
// There must be two intersection points.
p1 = p2 = v * r1;
double temp = ( r1 * r1 - r2 * r2 + d * d ) / ( 2 * d );
double angle = Math.Acos( temp / r1 );
Debug.Assert( !Tolerance.Zero( angle ) && !Tolerance.Equal( angle, Math.PI ) );
p1.RotateXY( angle );
p2.RotateXY( -angle );
p1 += c1.Center;
p2 += c1.Center;
return 2;
}
示例3: IntersectionLineCircle
public static int IntersectionLineCircle( Vector3D lineP1, Vector3D lineP2, Circle circle,
out Vector3D p1, out Vector3D p2 )
{
p1 = new Vector3D();
p2 = new Vector3D();
// Distance from the circle center to the closest point on the line.
double d = DistancePointLine( circle.Center, lineP1, lineP2 );
// No intersection points.
double r = circle.Radius;
if( d > r )
return 0;
// One intersection point.
p1 = ProjectOntoLine( circle.Center, lineP1, lineP2 );
if( Tolerance.Equal( d, r ) )
return 1;
// Two intersection points.
// Special case when the line goes through the circle center,
// because we can see numerical issues otherwise.
//
// I had further issues where my default tolerance was too strict for this check.
// The line was close to going through the center and the second block was used,
// so I had to loosen the tolerance used by my comparison macros.
if( Tolerance.Zero( d ) )
{
Vector3D line = lineP2 - lineP1;
line.Normalize();
line *= r;
p1 = circle.Center + line;
p2 = circle.Center - line;
}
else
{
// To origin.
p1 -= circle.Center;
p1.Normalize();
p1 *= r;
p2 = p1;
double angle = Math.Acos( d / r );
p1.RotateXY( angle );
p2.RotateXY( -angle );
// Back out.
p1 += circle.Center;
p2 += circle.Center;
}
return 2;
}
示例4: Verts
/// <summary>
/// Calculate the 4 points defining the fundamental geodesic quadrilateral.
/// </summary>
private static Vector3D[] Verts( int m, int k )
{
double dist1 = Math.PI / ( m + 1 );
double dist2 = Math.PI / ( k + 1 );
Vector3D p4 = new Vector3D( 1, 0 );
p4.RotateXY( dist2 );
return new Vector3D[]
{
new Vector3D(),
new Vector3D( 1, 0 ),
new Vector3D( 0, 0, Spherical2D.s2eNorm( dist1 ) ),
p4
};
}
示例5: 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;
}
示例6: IdealPoints
/// <summary>
/// Given a geodesic sphere, calculates 3 ideal points of the sphere.
/// </summary>
public static void IdealPoints( Sphere s, out Vector3D s1, out Vector3D s2, out Vector3D s3 )
{
if( s.IsPlane )
{
s1 = s.Offset;
s2 = s3 = s.Normal;
s2.RotateXY( Math.PI / 2 ); s2 += s1;
s3.RotateXY( -Math.PI / 2 ); s3 += s1;
return;
}
Vector3D cen = s.Center;
cen.Z = 0;
s1 = new Vector3D( s.Radius, 0 );
s2 = s3 = s1;
s2.RotateXY( Math.PI / 2 );
s3.RotateXY( Math.PI );
s1 += cen;
s2 += cen;
s3 += cen;
}
示例7: ApplyTransformation
/// <summary>
/// Using this to move the view around in interesting ways.
/// </summary>
private Vector3D ApplyTransformation( Vector3D v, double t = 0.0 )
{
//v.RotateXY( Math.PI / 4 + 0.01 );
bool applyNone = true;
if( applyNone )
return v;
Mobius m0 = new Mobius(), m1 = new Mobius(), m2 = new Mobius(), m3 = new Mobius();
Sphere unitSphere = new Sphere();
// self-similar scale for 437
//v*= 4.259171776329806;
double s = 6.5;
v *= s;
v += new Vector3D( s/3, -s/3 );
v = unitSphere.ReflectPoint( v );
v.RotateXY( Math.PI/6 );
//v /= 3;
//v.RotateXY( Math.PI );
//v.RotateXY( Math.PI/2 );
return v;
//v.Y = v.Y / Math.Cos( Math.PI / 6 ); // 637 repeatable
//return v;
// 12,12,12
m0.Isometry( Geometry.Hyperbolic, 0, new Complex( .0, .0 ) );
m1 = Mobius.Identity();
m2 = Mobius.Identity();
m3 = Mobius.Identity();
v = (m0 * m1 * m2 * m3).Apply( v );
return v;
// i64
m0.Isometry( Geometry.Hyperbolic, 0, new Complex( .5, .5 ) );
m1.UpperHalfPlane();
m2 = Mobius.Scale( 1.333333 );
m3.Isometry( Geometry.Euclidean, 0, new Vector3D( 0, -1.1 ) );
v = (m1 * m2 * m3).Apply( v );
return v;
// 464
// NOTE: Also, don't apply rotations during simplex generation.
m1.UpperHalfPlane();
m2 = Mobius.Scale( 1.3 );
m3.Isometry( Geometry.Euclidean, 0, new Vector3D( 1.55, -1.1 ) );
v = ( m1 * m2 * m3 ).Apply( v );
return v;
// iii
m1.Isometry( Geometry.Hyperbolic, 0, new Complex( 0, Math.Sqrt( 2 ) - 1 ) );
m2.Isometry( Geometry.Euclidean, -Math.PI / 4, 0 );
m3 = Mobius.Scale( 5 );
//v = ( m1 * m2 * m3 ).Apply( v );
// Vertical Line
/*v = unitSphere.ReflectPoint( v );
m1.MapPoints( new Vector3D(-1,0), new Vector3D(), new Vector3D( 1, 0 ) );
m2 = Mobius.Scale( .5 );
v = (m1*m2).Apply( v ); */
/*
m1 = Mobius.Scale( 0.175 );
v = unitSphere.ReflectPoint( v );
v = m1.Apply( v );
* */
// Inversion
//v = unitSphere.ReflectPoint( v );
//return v;
/*Mobius m1 = new Mobius(), m2 = new Mobius(), m3 = new Mobius();
m1.Isometry( Geometry.Spherical, 0, new Complex( 0, 1 ) );
m2.Isometry( Geometry.Euclidean, 0, new Complex( 0, -1 ) );
m3 = Mobius.Scale( 0.5 );
v = (m1 * m3 * m2).Apply( v );*/
//Mobius m = new Mobius();
//m.Isometry( Geometry.Hyperbolic, 0, new Complex( -0.88, 0 ) );
//m.Isometry( Geometry.Hyperbolic, 0, new Complex( 0, Math.Sqrt(2) - 1 ) );
//m = Mobius.Scale( 0.17 );
//m.Isometry( Geometry.Spherical, 0, new Complex( 0, 3.0 ) );
//v = m.Apply( v );
// 63i, 73i
m1 = Mobius.Scale( 6.0 ); // Scale {3,i} to unit disk.
m1 = Mobius.Scale( 1.0 / 0.14062592996431983 ); // 73i (constant is abs of midpoint of {3,7} tiling, if we want to calc later for other tilings).
m2.MapPoints( Infinity.InfinityVector, new Vector3D( 1, 0 ), new Vector3D() ); // swap interior/exterior
m3.UpperHalfPlane();
v *= 2.9;
// iii
/*m1.MapPoints( new Vector3D(), new Vector3D(1,0), new Vector3D( Math.Sqrt( 2 ) - 1, 0 ) );
m2.Isometry( Geometry.Euclidean, -Math.PI / 4, 0 );
m3 = Mobius.Scale( 0.75 );*/
//.........这里部分代码省略.........
示例8: VertexCenteredMobius
public static Mobius VertexCenteredMobius( int p, int q )
{
double angle = Math.PI / q;
if( Utils.Even( q ) )
angle *= 2;
Vector3D offset = new Vector3D( -1 * Geometry2D.GetNormalizedCircumRadius( p, q ), 0, 0 );
offset.RotateXY( angle );
Mobius m = new Mobius();
m.Isometry( Geometry2D.GetGeometry( p, q ), angle, offset.ToComplex() );
return m;
}
示例9: HyperidealSquares
private static void HyperidealSquares()
{
Mobius rot = new Mobius();
rot.Isometry( Geometry.Spherical, Math.PI / 4, new Vector3D() );
List<Segment> segs = new List<Segment>();
int[] qs = new int[] { 5, -1 };
foreach( int q in qs )
{
TilingConfig config = new TilingConfig( 4, q, 1 );
Tile t = Tiling.CreateBaseTile( config );
List<Segment> polySegs = t.Boundary.Segments;
polySegs = polySegs.Select( s => { s.Transform( rot ); return s; } ).ToList();
segs.AddRange( polySegs );
}
Vector3D v1 = new Vector3D(1,0);
v1.RotateXY( Math.PI/6 );
Vector3D v2 = v1;
v2.Y *= -1;
Vector3D cen;
double rad;
H3Models.Ball.OrthogonalCircle( v1, v2, out cen, out rad );
Segment seg = Segment.Arc( v1, v2, cen, false );
rot.Isometry( Geometry.Spherical, Math.PI / 2, new Vector3D() );
for( int i = 0; i < 4; i++ )
{
seg.Transform( rot );
segs.Add( seg.Clone() );
}
SVG.WriteSegments( "output1.svg", segs );
System.Func<Segment, Segment> PoincareToKlein = s =>
{
return Segment.Line(
HyperbolicModels.PoincareToKlein( s.P1 ),
HyperbolicModels.PoincareToKlein( s.P2 ) );
};
segs = segs.Select( s => PoincareToKlein( s ) ).ToList();
Vector3D v0 = new Vector3D( v1.X, v1.X );
Vector3D v3 = v0;
v3.Y *= -1;
Segment seg1 = Segment.Line( v0, v1 ), seg2 = Segment.Line( v2, v3 );
Segment seg3 = Segment.Line( new Vector3D( 1, 1 ), new Vector3D( 1, -1 ) );
for( int i = 0; i < 4; i++ )
{
seg1.Transform( rot );
seg2.Transform( rot );
seg3.Transform( rot );
segs.Add( seg1.Clone() );
segs.Add( seg2.Clone() );
segs.Add( seg3.Clone() );
}
SVG.WriteSegments( "output2.svg", segs );
}
示例10: TilePoints
/// <summary>
/// Helper to construct some points we need for calculating simplex facets for a {p,q,r} honeycomb.
/// </summary>
private static void TilePoints( int p, int q, out Vector3D p1, out Vector3D p2, out Vector3D p3, out Segment seg )
{
if( Infinite( p ) && Infinite( q ) /*&& FiniteOrInfinite( r )*/ )
{
p1 = new Vector3D( 1, 0, 0 );
p2 = new Vector3D( 0, Math.Sqrt( 2 ) - 1 );
p3 = Vector3D.DneVector();
Circle3D arcCircle;
H3Models.Ball.OrthogonalCircleInterior( p2, p1, out arcCircle );
seg = Segment.Arc( p1, p2, arcCircle.Center, clockwise: true );
}
else
{
Segment[] baseTileSegments;
if( Infinite( q ) )
baseTileSegments = BaseTileSegments( p, q ); // Can't use dual here.
else
baseTileSegments = BaseTileSegments( q, p ); // Intentionally using dual.
seg = baseTileSegments.First();
p1 = seg.P1;
p2 = seg.Midpoint;
p3 = p2;
p3.RotateXY( -Math.PI / 2 );
}
}