クラス名・変数名に迷ったら書き込むスレ。Part19
■ このスレッドは過去ログ倉庫に格納されています
0350デフォルトの名無しさん
2011/02/26(土) 23:23:30.65typedef struct { float x; float y } _point_t;
typedef struct { float w; float h } _size_t;
typedef struct { _point_t point; _size_t size } rect1;
typedef struct { _point_t from; _point_t to } rect2;
void rect1ToRect2 ( rect1 *r1, rect2 *r2 ) {
r2->from.x = r1->point.x;
r2->from.y = r1->point.y;
r2->to.x = r1->point.x + r1->size.w;
r2->to.y = r1->point.y + r1->size.h; // 座標系依存
}
void rect2ToRect1 ( rect2 *r2, rect1 *r1 ) {
r1->point.x = r2->from.x;
r1->point.y = r2->from.y;
r1->size.w = r2->to.x - r2->from.x;
r1->size.h = r2->to.y - r2->from.y; // 座標系依存
}
■ このスレッドは過去ログ倉庫に格納されています