Ich muss einen Bogen mit GraphicsPath zeichnen und Anfangs-, Median- und Endpunkte haben. Der Bogen muss sie passieren.C# Zeichnungsbogen mit 3 Punkten
Ich versuchte. DrawCurve und DrawBezier, aber das Ergebnis ist nicht genau ein Bogen.
Was kann ich tun?
LÖSUNG:
Nach ein paar Stunden Codeschreiben ich es geschafft, zu zeichnen, was ich mit diesem Algorithmus (um 3 Punkte a, b, c und einen Graphic Pfad) wollte:
double d = 2 * (a.X - c.X) * (c.Y - b.Y) + 2 * (b.X - c.X) * (a.Y - c.Y);
double m1 = (Math.Pow(a.X, 2) - Math.Pow(c.X, 2) + Math.Pow(a.Y, 2) - Math.Pow(c.Y, 2));
double m2 = (Math.Pow(c.X, 2) - Math.Pow(b.X, 2) + Math.Pow(c.Y, 2) - Math.Pow(b.Y, 2));
double nx = m1 * (c.Y - b.Y) + m2 * (c.Y - a.Y);
double ny = m1 * (b.X - c.X) + m2 * (a.X - c.X);
double cx = nx/d;
double cy = ny/d;
double dx = cx - a.X;
double dy = cy - a.Y;
double distance = Math.Sqrt(dx * dx + dy * dy);
Vector va = new Vector(a.X - cx, a.Y - cy);
Vector vb = new Vector(b.X - cx, b.Y - cy);
Vector vc = new Vector(c.X - cx, c.Y - cy);
Vector xaxis = new Vector(1, 0);
float startAngle = (float)Vector.AngleBetween(xaxis, va);
float sweepAngle = (float)(Vector.AngleBetween(va, vb) + Vector.AngleBetween(vb, vc));
path.AddArc(
(float)(cx - distance), (float)(cy - distance),
(float)(distance * 2), (float)(distance * 2),
startAngle, sweepAngle);
meinst du einen Kreisbogen, oder wird jeder Bogen tun? –
Rundschreiben, ich habe vergessen, dass – Keeper