本文整理汇总了C#中System.Numerics.Vector3.FindPerpendicularIn3d方法的典型用法代码示例。如果您正苦于以下问题:C# System.Numerics.Vector3.FindPerpendicularIn3d方法的具体用法?C# System.Numerics.Vector3.FindPerpendicularIn3d怎么用?C# System.Numerics.Vector3.FindPerpendicularIn3d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Numerics.Vector3
的用法示例。
在下文中一共展示了System.Numerics.Vector3.FindPerpendicularIn3d方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCircleOrDisk
// General purpose circle/disk drawing routine. Draws circles or disks (as
// specified by "filled" argument) and handles both special case 2d circles
// on the XZ plane or arbitrary circles in 3d space (as specified by "in3d"
// argument)
public static void DrawCircleOrDisk(float radius, Vector3 axis, Vector3 center, Color color, int segments, bool filled, bool in3D)
{
if (Demo.IsDrawPhase)
{
LocalSpace ls = new LocalSpace();
if (in3D)
{
// define a local space with "axis" as the Y/up direction
// (XXX should this be a method on LocalSpace?)
Vector3 unitAxis = Vector3.Normalize(axis);
Vector3 unitPerp = Vector3.Normalize(axis.FindPerpendicularIn3d());
ls.Up = unitAxis;
ls.Forward = unitPerp;
ls.Position = (center);
ls.SetUnitSideFromForwardAndUp();
}
// make disks visible (not culled) from both sides
if (filled) BeginDoubleSidedDrawing();
// point to be rotated about the (local) Y axis, angular step size
Vector3 pointOnCircle = new Vector3(radius, 0, 0);
float step = (float)(2 * Math.PI) / segments;
// set drawing color
SetColor(color);
// begin drawing a triangle fan (for disk) or line loop (for circle)
drawBegin(filled ? PrimitiveType.TriangleStrip : PrimitiveType.LineStrip);
// for the filled case, first emit the center point
if (filled) AddVertex(in3D ? ls.Position : center);
// rotate p around the circle in "segments" steps
float sin = 0, cos = 0;
int vertexCount = filled ? segments + 1 : segments;
for (int i = 0; i < vertexCount; i++)
{
// emit next point on circle, either in 3d (globalized out
// of the local space), or in 2d (offset from the center)
AddVertex(in3D ? ls.GlobalizePosition(pointOnCircle) : pointOnCircle + center);
// rotate point one more step around circle
pointOnCircle = pointOnCircle.RotateAboutGlobalY(step, ref sin, ref cos);
}
// close drawing operation
drawEnd();
if (filled) EndDoubleSidedDrawing();
}
else
{
DeferredCircle.AddToBuffer(radius, axis, center, color, segments, filled, in3D);
}
}