/// <summary> /// draws a 3d coordinate system overlay in the canonical volume /// </summary> /// <param name="draw"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="flipY"></param> public static void Draw(Direct2D.Context draw, Float3 x, Float3 y, Float3 z, bool flipY) { draw.FillCircle(Float2.Zero, 1.0f, new Color(0.5f)); // do some coordinate shuffling because of weird coordinate systems y = -y; z = -z; x = -x; x.X = -x.X; y.X = -y.X; z.X = -z.X; if (flipY) { y = -y; } var draws = new List <Drawable> { new Drawable(x, xColor, "x"), new Drawable(-x, xColor, null), new Drawable(y, yColor, "y"), new Drawable(-y, yColor, null), new Drawable(z, zColor, "z"), new Drawable(-z, zColor, null), }; draws.Sort(); foreach (var drawable in draws) { drawable.Draw(draw); } }
public void Draw(Direct2D.Context draw) { float labelThreshold = -0.05f; var lineColor = new Color(color.Red * 0.7f, color.Green * 0.7f, color.Blue * 0.7f); var center = vector.XY * radius; if (label != null && vector.Z >= labelThreshold) { draw.Line(Float2.Zero, center, stroke, lineColor); } draw.FillCircle(center, circleRadius, color); if (label == null) { return; } var tl = center + new Float2(-textRadius, textRadius); var tr = center + new Float2(textRadius, textRadius); var bl = center + new Float2(-textRadius, -textRadius); var br = center + new Float2(textRadius, -textRadius); switch (label) { case "x": draw.Line(tl, br, textStroke, Colors.Black); draw.Line(tr, bl, textStroke, Colors.Black); break; case "y": draw.Line(center, tl, textStroke, Colors.Black); draw.Line(center, tr, textStroke, Colors.Black); draw.Line(center, center - new Float2(0.0f, textRadius), textStroke, Colors.Black); break; case "z": draw.Line(tl, tr, textStroke, Colors.Black); draw.Line(tr, bl, textStroke, Colors.Black); draw.Line(bl, br, textStroke, Colors.Black); break; } if (label != null && vector.Z <= labelThreshold) { draw.Line(Float2.Zero, center, stroke, lineColor); } }