mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-26 15:06:22 +01:00
24 lines
No EOL
593 B
Text
24 lines
No EOL
593 B
Text
function point_rectangle_overlap(w, h, angle) {
|
|
var x0, y0;
|
|
var a1 = radtodeg(arctan2(h, w));
|
|
var a2 = 90 - a1;
|
|
|
|
if(angle < a1) {
|
|
x0 = w;
|
|
y0 = h / 2 - w / 2 * tan(degtorad(angle));
|
|
} else if(angle < a1 + a2 * 2) {
|
|
x0 = w / 2 - h / 2 * tan(degtorad(angle - 90));
|
|
y0 = 0;
|
|
} else if(angle < a1 + a2 * 2 + a1 * 2) {
|
|
x0 = 0;
|
|
y0 = h / 2 + w / 2 * tan(degtorad(angle - 180));
|
|
} else if(angle < a1 + a2 * 2 + a1 * 2 + a2 * 2) {
|
|
x0 = w / 2 + h / 2 * tan(degtorad(angle - 270));
|
|
y0 = h;
|
|
} else {
|
|
x0 = w;
|
|
y0 = h / 2 - w / 2 * tan(degtorad(angle));
|
|
}
|
|
|
|
return [x0, y0];
|
|
} |