17 tfloat cot_alpha = Cot( alpha2 - alpha1 ) ;
18 tfloat cot_beta = Cot( alpha3 - alpha2 ) ;
19 cot_alpha = adjust_value_to_bounds( cot_alpha , COT_MAX ) ;
20 cot_beta = adjust_value_to_bounds( cot_beta , COT_MAX ) ;
22 tfloat phi = atan2( (y3-y2) , (x3-x2) ) ;
23 tfloat sin_phi = Sin(phi) ;
24 tfloat cos_phi = Cos(phi) ;
26 tfloat x3r = cos_phi * ( x3 - x2 ) + sin_phi * ( y3 - y2 ) ;
27 tfloat x1r = cos_phi * ( x1 - x2 ) + sin_phi * ( y1 - y2 ) ;
28 tfloat y1r = -sin_phi * ( x1 - x2 ) + cos_phi * ( y1 - y2 ) ;
30 tfloat eta = ( x3r - x1r - y1r*cot_alpha ) / ( x3r*cot_beta - y1r + x1r*cot_alpha ) ;
32 tfloat k = ( 1 - eta*cot_beta ) / ( 1 + eta*eta ) ;
37 *x = x2 + cos_phi * xr - sin_phi * yr ;
38 *y = y2 + sin_phi * xr + cos_phi * yr ;
50 tfloat alpha12 = alpha2 - alpha1 ;
51 tfloat alpha23 = alpha3 - alpha2 ;
54 tfloat mB = Cot( theta - alpha12 ) ;
55 tfloat mC = Cot( theta - alpha12 - alpha23 ) ;
56 mA = adjust_value_to_bounds( mA , COT_MAX ) ;
57 mB = adjust_value_to_bounds( mB , COT_MAX ) ;
58 mC = adjust_value_to_bounds( mC , COT_MAX ) ;
60 tfloat xPAB = ( mA * x1 - mB * x2 - y1 + y2 ) / ( mA - mB ) ;
61 tfloat yPAB = mA * ( xPAB - x1 ) + y1 ;
62 tfloat xPBC = ( mB * x2 - mC * x3 - y2 + y3 ) / ( mB - mC ) ;
63 tfloat yPBC = mB * ( xPBC - x2 ) + y2 ;
64 tfloat xPAC = ( mA * x1 - mC * x3 - y1 + y3 ) / ( mA - mC ) ;
65 tfloat yPAC = mA * ( xPAC - x1 ) + y1 ;
67 tfloat Ap = ( ( xPAB - xPBC ) * ( yPBC - yPAC ) - ( xPBC - xPAC ) * ( yPAB - yPBC ) ) ;
68 Ap = ( Ap < 0.0 ) ? -Ap : Ap ;
70 tfloat cot_12 = Cot( alpha12 ) ;
71 tfloat cot_23 = Cot( alpha23 ) ;
72 tfloat cot_31 = ( 1.0 - cot_12 * cot_23 ) / ( cot_12 + cot_23 ) ;
73 cot_12 = adjust_value_to_bounds( cot_12 , COT_MAX ) ;
74 cot_23 = adjust_value_to_bounds( cot_23 , COT_MAX ) ;
75 cot_31 = adjust_value_to_bounds( cot_31 , COT_MAX ) ;
77 tfloat xCAB = ( x1 + x2 + ( y1 - y2 ) * cot_12 ) ;
78 tfloat yCAB = ( y1 + y2 + ( x2 - x1 ) * cot_12 ) ;
79 tfloat xCBC = ( x2 + x3 + ( y2 - y3 ) * cot_23 ) ;
80 tfloat yCBC = ( y2 + y3 + ( x3 - x2 ) * cot_23 ) ;
81 tfloat xCAC = ( x1 + x3 - ( y1 - y3 ) * cot_31 ) ;
82 tfloat yCAC = ( y1 + y3 - ( x3 - x1 ) * cot_31 ) ;
84 tfloat Ac = ( ( xCAB - xCBC ) * ( yCBC - yCAC ) - ( xCBC - xCAC ) * ( yCAB - yCBC ) ) ;
85 Ac = ( Ac < 0.0 ) ? -Ac : Ac ;
87 tfloat delta_theta = asin( sqrt( Ap / Ac ) ) ;
88 delta_theta = ( delta_theta < 0.0 ) ? -delta_theta : delta_theta ;
90 tfloat S = ( xPBC - xPAB ) * ( yCBC - yCAB ) - ( xCBC - xCAB ) * ( yPBC - yPAB ) ;
91 if ( S < 0.0 ) delta_theta = -delta_theta ;
93 theta += delta_theta ;
96 mB = Cot( theta - alpha12 ) ;
97 mA = adjust_value_to_bounds( mA , COT_MAX ) ;
98 mB = adjust_value_to_bounds( mB , COT_MAX ) ;
100 *x = ( mA * x1 - mB * x2 - y1 + y2 ) / ( mA - mB ) ;
101 *y = mA * ( (*x) - x1 ) + y1 ;
double tfloat
Defines the type for float/double.