20 tfloat cot_12 = Cot( alpha2 - alpha1 ) ;
21 tfloat cot_23 = Cot( alpha3 - alpha2 ) ;
22 cot_12 = adjust_value_to_bounds( cot_12 , COT_MAX ) ;
23 cot_23 = adjust_value_to_bounds( cot_23 , COT_MAX ) ;
24 tfloat cot_31 = ( 1.0 - cot_12 * cot_23 ) / ( cot_12 + cot_23 ) ;
25 cot_31 = adjust_value_to_bounds( cot_31 , COT_MAX ) ;
27 tfloat x1_ = x1 - x2 , y1_ = y1 - y2 , x3_ = x3 - x2 , y3_ = y3 - y2 ;
29 tfloat c12x = x1_ + cot_12 * y1_ ;
30 tfloat c12y = y1_ - cot_12 * x1_ ;
32 tfloat c23x = x3_ - cot_23 * y3_ ;
33 tfloat c23y = y3_ + cot_23 * x3_ ;
35 tfloat c31x = (x3_ + x1_) + cot_31 * (y3_ - y1_) ;
36 tfloat c31y = (y3_ + y1_) - cot_31 * (x3_ - x1_) ;
37 tfloat k31 = (x3_ * x1_) + (y3_ * y1_) + cot_31 * ( (y3_ * x1_) - (x3_ * y1_) ) ;
39 tfloat D = (c12x - c23x) * (c23y - c31y) - (c23x - c31x) * (c12y - c23y) ;
43 *x = K * (c12y - c23y) + x2 ;
44 *y = K * (c23x - c12x) + y2 ;
56 tfloat alpha_12 = alpha2 - alpha1 ;
57 tfloat alpha_23 = alpha3 - alpha2 ;
58 tfloat alpha_31 = alpha1 - alpha3 ;
60 tfloat x1_ , y1_ , x2_ , y2_ , x3_ , y3_ ;
62 tfloat cot_12 , cot_23 , cot_31 , c12x , c12y , c23x , c23y , c31x , c31y , k , D , invD , K ;
64 if ( alpha_12 ==
PI || alpha_12 == 0.0 )
66 x1_ = x1 - x3 , y1_ = y1 - y3 , x2_ = x2 - x3 , y2_ = y2 - y3 ;
68 cot_23 = cot( alpha_23 ) ;
72 k = (y1_ * x2_) - (x1_ * y2_) ;
74 c23x = x2_ + cot_23 * y2_ ;
75 c23y = y2_ - cot_23 * x2_ ;
77 c31x = x1_ + cot_23 * y1_ ;
78 c31y = y1_ - cot_23 * x1_ ;
80 D = (c31x - c23x) * (c12y) + (c12x) * (c23y - c31y) ;
84 *x = K * ( c23y - c31y ) + x3 ;
85 *y = K * ( c31x - c23x ) + y3 ;
90 if ( alpha_23 ==
PI || alpha_23 == 0.0 )
92 x2_ = x2 - x1 , y2_ = y2 - y1 , x3_ = x3 - x1 , y3_ = y3 - y1 ;
94 cot_31 = cot( alpha_31 ) ;
96 c12x = x2_ + cot_31 * y2_ ;
97 c12y = y2_ - cot_31 * x2_ ;
101 k = (y2_ * x3_) - (x2_ * y3_) ;
103 c31x = x3_ + cot_31 * y3_ ;
104 c31y = y3_ - cot_31 * x3_ ;
106 D = (c12x - c31x) * (c23y) + (c23x) * (c31y - c12y) ;
110 *x = K * ( c31y - c12y ) + x1 ;
111 *y = K * ( c12x - c31x ) + y1 ;
116 if ( alpha_31 ==
PI || alpha_31 == 0.0 )
118 x1_ = x1 - x2 , y1_ = y1 - y2 , x3_ = x3 - x2 , y3_ = y3 - y2 ;
120 cot_12 = cot( alpha_12 ) ;
122 c12x = x1_ + cot_12 * y1_ ;
123 c12y = y1_ - cot_12 * x1_ ;
125 c23x = x3_ + cot_12 * y3_ ;
126 c23y = y3_ - cot_12 * x3_ ;
130 k = (y3_ * x1_) - (x3_ * y1_) ;
132 D = (c23x - c12x) * (c31y) + (c31x) * (c12y - c23y) ;
136 *x = K * (c12y - c23y) + x2 ;
137 *y = K * (c23x - c12x) + y2 ;
142 x1_ = x1 - x2 , y1_ = y1 - y2 , x3_ = x3 - x2 , y3_ = y3 - y2 ;
144 cot_12 = cot( alpha_12 ) ;
145 cot_23 = cot( alpha_23 ) ;
146 cot_31 = ( 1.0 - cot_12*cot_23 ) / (cot_12 + cot_23) ;
148 c12x = x1_ + cot_12 * y1_ ;
149 c12y = y1_ - cot_12 * x1_ ;
151 c23x = x3_ - cot_23 * y3_ ;
152 c23y = y3_ + cot_23 * x3_ ;
154 c31x = (x3_ + x1_) + cot_31 * (y3_ - y1_) ;
155 c31y = (y3_ + y1_) - cot_31 * (x3_ - x1_) ;
156 k = (x3_ * x1_) + (y3_ * y1_) + cot_31 * ( (y3_ * x1_) - (x3_ * y1_) ) ;
158 D = (c12x - c23x) * (c23y - c31y) - (c23x - c31x) * (c12y - c23y) ;
162 *x = K * (c12y - c23y) + x2 ;
163 *y = K * (c23x - c12x) + y2 ;
#define PI
The value of PI.
double tfloat
Defines the type for float/double.
tfloat triangulationPierlot(tfloat *x, tfloat *y, tfloat alpha1, tfloat alpha2, tfloat alpha3, tfloat x1, tfloat y1, tfloat x2, tfloat y2, tfloat x3, tfloat y3)