@@ -26,21 +26,21 @@ public class Triangle2D {
2626 [ SerializeField ] public Edge2D [ ] Edges ;
2727 [ SerializeField ] public Vector2 [ ] Vertices ;
2828
29- internal Vector2 A => Vertices [ 0 ] ;
30- internal Vector2 B => Vertices [ 1 ] ;
31- internal Vector2 C => Vertices [ 2 ] ;
29+ public Vector2 A => Vertices [ 0 ] ;
30+ public Vector2 B => Vertices [ 1 ] ;
31+ public Vector2 C => Vertices [ 2 ] ;
3232
33- [ SerializeField ] internal Vector2 Circumcenter ;
34- [ SerializeField ] internal double RadiusSquared ;
33+ [ SerializeField ] public Vector2 Circumcenter ;
34+ [ SerializeField ] public double RadiusSquared ;
3535
3636 public Triangle2D ( Vector2 a , Vector2 b , Vector2 c ) {
3737 Vertices = ! IsCounterClockwise ( a , b , c ) ? new [ ] { a , c , b } : new [ ] { a , b , c } ;
3838 Edges = new [ ] { new Edge2D ( Vertices [ 0 ] , Vertices [ 1 ] ) , new Edge2D ( Vertices [ 1 ] , Vertices [ 2 ] ) , new Edge2D ( Vertices [ 2 ] , Vertices [ 0 ] ) } ;
3939 UpdateCircumcircle ( ) ;
4040 }
4141
42- public Triangle2D ( Edge2D a , Edge2D b , Vector2 c ) {
43- Vertices = ! IsCounterClockwise ( a . Vertices [ 0 ] , b . Vertices [ 0 ] , c ) ? new [ ] { a . Vertices [ 0 ] , c , b . Vertices [ 0 ] } : new [ ] { a . Vertices [ 0 ] , b . Vertices [ 0 ] , c } ;
42+ public Triangle2D ( Edge2D a , Vector2 b ) {
43+ Vertices = ! IsCounterClockwise ( a . Vertices [ 0 ] , a . Vertices [ 1 ] , b ) ? new [ ] { a . Vertices [ 0 ] , b , a . Vertices [ 1 ] } : new [ ] { a . Vertices [ 0 ] , a . Vertices [ 1 ] , b } ;
4444 Edges = new [ ] { new Edge2D ( Vertices [ 0 ] , Vertices [ 1 ] ) , new Edge2D ( Vertices [ 1 ] , Vertices [ 2 ] ) , new Edge2D ( Vertices [ 2 ] , Vertices [ 0 ] ) } ;
4545 UpdateCircumcircle ( ) ;
4646 }
@@ -77,20 +77,20 @@ public void UpdateCircumcircle() {
7777 Vector2 p1 = Vertices [ 1 ] ;
7878 Vector2 p2 = Vertices [ 2 ] ;
7979
80- float dA = p0 . x * p0 . x + p0 . y * p0 . y ;
81- float dB = p1 . x * p1 . x + p1 . y * p1 . y ;
82- float dC = p2 . x * p2 . x + p2 . y * p2 . y ;
80+ double dA = p0 . x * p0 . x + p0 . y * p0 . y ;
81+ double dB = p1 . x * p1 . x + p1 . y * p1 . y ;
82+ double dC = p2 . x * p2 . x + p2 . y * p2 . y ;
8383
84- float aux1 = dA * ( p2 . y - p1 . y ) + dB * ( p0 . y - p2 . y ) + dC * ( p1 . y - p0 . y ) ;
85- float aux2 = - ( dA * ( p2 . x - p1 . x ) + dB * ( p0 . x - p2 . x ) + dC * ( p1 . x - p0 . x ) ) ;
86- float div = 2 * ( p0 . x * ( p2 . y - p1 . y ) + p1 . x * ( p0 . y - p2 . y ) + p2 . x * ( p1 . y - p0 . y ) ) ;
84+ double aux1 = dA * ( p2 . y - p1 . y ) + dB * ( p0 . y - p2 . y ) + dC * ( p1 . y - p0 . y ) ;
85+ double aux2 = - ( dA * ( p2 . x - p1 . x ) + dB * ( p0 . x - p2 . x ) + dC * ( p1 . x - p0 . x ) ) ;
86+ double div = 2 * ( p0 . x * ( p2 . y - p1 . y ) + p1 . x * ( p0 . y - p2 . y ) + p2 . x * ( p1 . y - p0 . y ) ) ;
8787
8888 if ( div == 0 ) {
8989 Debug . LogWarning ( "Division by 0 caught. UpdateCircumcircle() did not complete." ) ;
9090 return ;
9191 }
9292
93- Vector2 Center = new ( aux1 / div , aux2 / div ) ;
93+ Vector2 Center = new ( ( float ) ( aux1 / div ) , ( float ) ( aux2 / div ) ) ;
9494
9595 Circumcenter = Center ;
9696 RadiusSquared = ( Center . x - p0 . x ) * ( Center . x - p0 . x ) + ( Center . y - p0 . y ) * ( Center . y - p0 . y ) ;
0 commit comments