154 |
float x = xy[0] + size[0]/2; |
float x = xy[0] + size[0]/2; |
155 |
float y = xy[1] + size[1]/2; |
float y = xy[1] + size[1]/2; |
156 |
|
|
157 |
//pa("anchor x/y: "+x+"/"+y); |
// distance/legth from center to anchor |
|
|
|
158 |
len = (float)Math.sqrt( (x-cx)*(x-cx) + (y-cy)*(y-cy) ); |
len = (float)Math.sqrt( (x-cx)*(x-cx) + (y-cy)*(y-cy) ); |
159 |
|
|
|
//pa("len: "+len+", rad: "+rad); |
|
|
|
|
160 |
// if len is longer than rad - do nothing. |
// if len is longer than rad - do nothing. |
|
float wh = min; |
|
161 |
int cs = anchor; |
int cs = anchor; |
|
if (len <= rad) { |
|
162 |
|
|
163 |
// project and translate buoy |
// project and translate buoy |
164 |
|
if (len <= rad) { |
165 |
|
|
166 |
// angular coefficient |
// angular coefficient |
167 |
float ac = 1; |
float ac = 1; |
168 |
if (px-x != 0) // tan a = y/x |
if (px-x != 0) // tan a = y/x |
169 |
ac = (py-y)/(px-x); |
ac = (py-y)/(px-x); |
170 |
|
|
171 |
//cs = orthoBox(0, (len/rad)*100,cx + (float)Math.cos(ac)*rad/2, |
float boxSize = max - (max-min)*(len/rad); |
172 |
cs = orthoBox(0, (len/rad)*99f,cx + (float)Math.cos(ac)*rad/2, |
if (px <= x) { |
173 |
cy + (float)Math.sin(ac)*rad, 1,1, 50,50 ); |
if (ac < 1 && ac >= -1) |
174 |
// box size not counted XXX XXX |
cs = orthoBox(0, (len/rad)*99f, // most close go up - others down. |
175 |
|
cx + (float)Math.cos(ac)*rad, // x |
176 |
|
cy + (float)Math.sin(ac)*rad, 1,1, boxSize,boxSize ); |
177 |
|
else |
178 |
|
cs = orthoBox(0, (len/rad)*99f, // most close go up - others down. |
179 |
|
cx - (float)Math.cos(ac)*rad, // x |
180 |
|
cy + (float)Math.sin(ac)*rad, 1,1, boxSize,boxSize ); |
181 |
|
} else { |
182 |
|
if (ac < 1 && ac >= -1) |
183 |
|
cs = orthoBox(0, (len/rad)*99f, // most close go up - others down. |
184 |
|
cx - (float)Math.cos(ac)*rad, // x |
185 |
|
cy + (float)Math.sin(ac)*rad, 1,1, boxSize,boxSize ); |
186 |
|
else |
187 |
|
cs = orthoBox(0, (len/rad)*99f, // most close go up - others down. |
188 |
|
cx + (float)Math.cos(ac)*rad, // x |
189 |
|
cy + (float)Math.sin(ac)*rad, 1,1, boxSize,boxSize ); |
190 |
|
} |
191 |
} |
} |
|
// proper box |
|
|
//cs = orthoBox(cs, 0, -wh/2, -wh/2, 1,1, wh,wh); |
|
|
|
|
|
// XXX macthing? |
|
192 |
return cs; |
return cs; |
193 |
} |
} |
194 |
|
|