143 |
public int buoyOnCircle(int into, int anchor, float cx, float cy, float rad, |
public int buoyOnCircle(int into, int anchor, float cx, float cy, float rad, |
144 |
float px, float py, float min, float max) |
float px, float py, float min, float max) |
145 |
{ |
{ |
|
pa("buoy.."); |
|
|
|
|
146 |
// check how far from center point anchor is |
// check how far from center point anchor is |
147 |
float len = 0; |
float len = 0; |
148 |
float [] size = new float[2]; |
float [] size = new float[2]; |
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); |
//pa("anchor x/y: "+x+"/"+y); |
158 |
|
|
159 |
len = (float)Math.sqrt( (x-cx)*(x-cx) + (y-cy)*(y-cy) ); |
len = (float)Math.sqrt( (x-cx)*(x-cx) + (y-cy)*(y-cy) ); |
160 |
|
|
161 |
pa("len: "+len+", rad: "+rad); |
//pa("len: "+len+", rad: "+rad); |
162 |
|
|
163 |
// if len is longer than rad - do nothing. |
// if len is longer than rad - do nothing. |
164 |
float wh = min; |
float wh = min; |
165 |
int cs = anchor; |
int cs = anchor; |
166 |
if (len <= rad || true) { |
if (len <= rad) { |
|
pa("in buoyCS"); |
|
167 |
|
|
168 |
// project and translate buoy |
// project and translate buoy |
169 |
|
|
172 |
if (px-x != 0) // tan a = y/x |
if (px-x != 0) // tan a = y/x |
173 |
ac = (py-y)/(px-x); |
ac = (py-y)/(px-x); |
174 |
|
|
|
cs = translate(into, (float)Math.cos(ac)*rad/2, |
|
|
(float)Math.sin(ac)*rad, (len/rad)*100 ); |
|
|
|
|
175 |
//cs = orthoBox(0, (len/rad)*100,cx + (float)Math.cos(ac)*rad/2, |
//cs = orthoBox(0, (len/rad)*100,cx + (float)Math.cos(ac)*rad/2, |
176 |
cs = orthoBox(0, 10f,cx + (float)Math.cos(ac)*rad/2, |
cs = orthoBox(0, (len/rad)*99f,cx + (float)Math.cos(ac)*rad/2, |
177 |
cy + (float)Math.sin(ac)*rad, 1,1, 50,50 ); |
cy + (float)Math.sin(ac)*rad, 1,1, 50,50 ); |
178 |
// box size not counted XXX XXX |
// box size not counted XXX XXX |
179 |
|
|