Risposte:
È possibile utilizzare il prodotto punto per questo
/// <summary>
/// Used to indicate the orientation of an object in space
/// with respect to another object
/// </summary>
public enum OrientationType
{
Left,
Right,
Coincident,
Unknown
}
/// <summary>
/// Determines if a point is oriented left, right or coincident with
/// a directed line.
/// Line direction is determined by its From and To points.
/// </summary>
/// <param name="p">The point to test.</param>
/// <param name="segment">The line dividing the space</param>
/// <returns>An OrientationType indicating the orientation.</returns>
public static OrientationType GetPointOrientation(IPoint p, ISegment segment)
{
OrientationType result = OrientationType.Unknown;
double Ax = segment.FromPoint.X;
double Ay = segment.FromPoint.Y;
double Bx = segment.ToPoint.X;
double By = segment.ToPoint.Y;
double Px = p.X;
double Py = p.Y;
double nDotV = ((Ay - By) * (Px - Ax)) + ((Bx - Ax) * (Py - Ay));
if (nDotV < 0)
{
result = OrientationType.Right;//opposite direction to normal vector
}
else if (nDotV > 0)
{
result = OrientationType.Left;
}
else if (nDotV == 0)
{
result = OrientationType.Coincident;
}
return result;
}
Algoritmo per ottenere il risultato desiderato: