using System.Runtime.CompilerServices;
namespace GeometriCS
{
///
/// A line through a two-dimensional vector space.
///
///
/// Line follows the equation Ax + By + C = 0
///
public class Line2d
{
///
/// A coefficient of the line.
///
///
/// Line follows the equation Ax + By + C = 0
///
public double Coeff_A { get; set; }
///
/// B coefficient of the line.
///
///
/// Line follows the equation Ax + By + C = 0
///
public double Coeff_B { get; set; }
///
/// C coefficient of the line.
///
///
/// Line follows the equation Ax + By + C = 0
///
public double Coeff_C { get; set; }
///
/// Construct a line from a point on the line and a direction vector.
///
/// Point that lies on the line.
/// Direction the line takes from the point.
/// Line2d passing throught the given point with the given direction.
public static Line2d FromPointAndDirection(Vector2d pointOnLine, Vector2d direction)
{
throw new NotImplementedException();
}
///
/// Construct a line passing through two given points.
///
/// First point that lies on the line.
/// Other point that lies on the line.
/// Line passing through the two points.
public static Line2d FromTwoPoints(Vector2d firstPoint, Vector2d secondPoint)
{
throw new NotImplementedException();
}
///
/// Construct the line from its coefficients.
///
///
///
///
public Line2d(double coeff_A, double coeff_B, double coeff_C)
{
Coeff_A = coeff_A;
Coeff_B = coeff_B;
Coeff_C = coeff_C;
}
///
/// String representation of the line.
///
///
public override string ToString()
{
throw new NotImplementedException();
}
///
/// Do the two objects represent the same line?
///
/// Object to compare.
///
/// true if the lines have the same coefficients. Otherwise false
public override bool Equals(object? obj)
{
if (obj is Line2d asLn)
{
return this == asLn;
}
else
{
return false;
}
}
public override int GetHashCode()
{
return HashCode.Combine(Coeff_A, Coeff_B, Coeff_C);
}
///
/// Deep copy the line.
///
/// Deep copy of the line.
public object Clone()
{
return new Line2d(Coeff_A, Coeff_B, Coeff_C);
}
///
/// Are the lines equal?
///
/// First line.
/// Second line.
/// true if the lines have the same start and end points. Otherwise false
public static bool operator ==(Line2d a, Line2d b)
{
return Utils.DoubleEquals(a.Coeff_A, b.Coeff_A) && Utils.DoubleEquals(a.Coeff_B, b.Coeff_B) && Utils.DoubleEquals(a.Coeff_C, b.Coeff_C);
}
///
/// Are the lines different?
///
/// First line.
/// Second line.
/// true If the lines have the same coefficients. Otherwise false.
public static bool operator !=(Line2d a, Line2d b)
{
return !(a == b);
}
}
}