32 lines
943 B
C#
32 lines
943 B
C#
using StructureHelperCommon.Models.Shapes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FieldVisualizer.Entities.Values.Primitives
|
|
{
|
|
public class TrianglePrimitive : ITrianglePrimitive
|
|
{
|
|
public double Value { get; set; }
|
|
|
|
public IPoint2D Point1 { get; set; }
|
|
public IPoint2D Point2 { get; set; }
|
|
public IPoint2D Point3 { get; set; }
|
|
|
|
// --- Computed properties ---
|
|
|
|
// Centroid (geometric center)
|
|
public double CenterX => (Point1.X + Point2.X + Point3.X) / 3.0;
|
|
public double CenterY => (Point1.Y + Point2.Y + Point3.Y) / 3.0;
|
|
|
|
// Triangle area using determinant formula
|
|
public double Area =>
|
|
0.5 * Math.Abs(
|
|
(Point2.X - Point1.X) * (Point3.Y - Point1.Y) -
|
|
(Point3.X - Point1.X) * (Point2.Y - Point1.Y)
|
|
);
|
|
}
|
|
}
|