, 내 머리는소개 : 사각형 회전 및 하드 작업 후 피팅
내가 회전 작업 :
변수를하고있는 중이 야 (가 터키에서 오후 11시 40분입니다) .. 서비스 밝혀 :
_cx = horizontal center of rect
_cy = vertical center of rect
_cos = cos value of current angle
_sin = sin value of current angle
to rotating any point in this rect :
function getx(x, y)
{
return _cx + _cos * (x - _cx) - _sin * (y - _cy);
}
function gety(x, y)
{
return _cy + _sin * (x - _cx) + _cos * (y - _cy);
}
원본 크기로 회전 처리하기 전에 주어진 사각형 크기를 조정하려고합니다. 어떻게해야합니까?
주셔서 감사합니다 사전
편집 : 이고르 Krivokon의 솔루션 문제는 여기 이고르 Krivokon에 의해 해결되고
모든 각도 값
var h1:Number, h2:Number, hh:Number, ww:Number,
degt:Number, d2r:Number, r2d:Number, deg:Number,
sint:Number, cost:Number;
//@angle = given angle in radians
//@r is source/target rectangle
//@d2r is static PI/180 constant for degree -> radian conversation
//@r2d is static 180/PI constant for radian -> degree conversation
d2r = 0.017453292519943295769236907683141;
r2d = 57.295779513082320876798154814105;
deg = Math.abs(angle * r2d) % 360;
if(deg < 91)
{
degt = angle;
}else if(deg < 181){
degt = (180 - deg) * d2r;
}else if(deg < 271){
degt = (deg - 180) * d2r;
}else{
degt = (360 - deg) * d2r;
}
sint = Math.sin(degt);
cost = Math.cos(degt);
h1 = r.height * r.height/(r.width * sint + r.height * cost);
h2 = r.height * r.width/(r.width * cost + r.height * sint);
hh = Math.min(h1, h2);
ww = hh * r.width/r.height;
r.x = (r.width - ww) * .5;
r.y = (r.height - hh) * .5;
r.height = hh;
r.width = ww;
을 위해 작동하는 무슨이 해당 솔루션의 수정 된 버전입니다
감사합니다.
빠른 해명, 당신은 사각형 R을 가지고 있고 당신은 사각형 R을 생산하기 위해 회전 중심에 대해 그것을 확장 할 '가능한 한 R의 많은 부분을 차지합니까? –
안녕하세요 Tolgahan, 적어도 사각형의 변 사이의 관계를 알지 못해도 대답 할 수 없습니다. – tekBlues
예, 회전하기 전에 R을 갖고 싶습니다. –