@@ -110,11 +110,17 @@ static void computeSharkfin(IList<double> mfX, IList<double> mfY, IList<double>
110110
111111 for ( int i = 0 ; i < n ; i ++ ) {
112112 var XYZ = mfX [ i ] + mfY [ i ] + mfZ [ i ] ;
113- Sharkfin [ i ] = new xyYPoint { x = mfX [ i ] / XYZ , y = mfY [ i ] / XYZ } ;
113+
114+ if ( Math . Abs ( XYZ ) < double . Epsilon ) {
115+ Sharkfin [ i ] = new xyYPoint { x = 0.0 , y = 0.0 } ;
116+ } else {
117+ Sharkfin [ i ] = new xyYPoint { x = mfX [ i ] / XYZ , y = mfY [ i ] / XYZ } ;
118+ }
114119 }
115120
116121 // Used to speedup the convex hull algorithm
117122 SortedSharkfin = ( xyYPoint [ ] ) Sharkfin . Clone ( ) ;
123+
118124 Array . Sort ( SortedSharkfin , new xyYPointComparer ( ) ) ;
119125 }
120126
@@ -140,15 +146,23 @@ public CIExyY (double x, double y, double Y, AConvertibleColor dataSource=null)
140146 /**
141147 * <inheritdoc />
142148 */
143- public override bool IsInsideColorSpace ( )
149+ public override bool IsInsideColorSpace ( bool highPrecision = false )
144150 {
145151 // Fast checks
146152 if ( y > 1.0 - x || y < ( x - 0.25 ) * 0.5 || y < 0.4 - x * 4 || y >= 0.85 )
147153 return false ;
148154
149- xyYPoint [ ] points = new xyYPoint [ SortedSharkfin5Nm . Length + 1 ] ;
150- Array . Copy ( SortedSharkfin5Nm , 0 , points , 0 , SortedSharkfin5Nm . Length ) ;
151- points [ SortedSharkfin5Nm . Length ] = new xyYPoint { x = x , y = y } ;
155+ xyYPoint [ ] points ;
156+
157+ if ( highPrecision ) {
158+ points = new xyYPoint [ SortedSharkfin1Nm . Length + 1 ] ;
159+ Array . Copy ( SortedSharkfin1Nm , 0 , points , 0 , SortedSharkfin1Nm . Length ) ;
160+ points [ SortedSharkfin1Nm . Length ] = new xyYPoint { x = x , y = y } ;
161+ } else {
162+ points = new xyYPoint [ SortedSharkfin5Nm . Length + 1 ] ;
163+ Array . Copy ( SortedSharkfin5Nm , 0 , points , 0 , SortedSharkfin5Nm . Length ) ;
164+ points [ SortedSharkfin5Nm . Length ] = new xyYPoint { x = x , y = y } ;
165+ }
152166
153167 xyYPoint [ ] convexHull = findConvexHull ( points ) ;
154168
@@ -191,7 +205,7 @@ public override bool Equals(Object obj)
191205 if ( xyYObj == this ) {
192206 return true ;
193207 }
194- if ( xyYObj == null || GetHashCode ( ) != obj . GetHashCode ( ) ) {
208+ if ( xyYObj == null ) {
195209 return false ;
196210 }
197211
0 commit comments