Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Pos
- {
- Pos() : x(0), y(0) {}
- Pos(float _x, float _y) : x(_x), y(_y) {}
- float x, y;
- };
- Pos A(-1000000.0f, 0.0f);
- Pos B(0.0f, 1000000.0f);
- Pos C(1000000, 0.0f);
- Pos O;
- O.y = ((C.x * C.x + C.y * C.y - A.x * A.x - A.y * A.y) * (B.x - A.x) - (B.x * B.x + B.y * B.y - A.x * A.x - A.y * A.y) * (C.x - A.x));
- O.y /= 2.0f * ((A.y - B.y) * (C.x - A.x) - (A.y - C.y) * (B.x - A.x));
- Pos &CH = (fabs(C.x - A.x) < 0.01f)?B:C;
- O.x = (CH.x * CH.x + CH.y * CH.y - A.x * A.x - A.y * A.y + 2 * O.y * (A.y - CH.y));
- O.x /= 2.0f * (CH.x - A.x);
- printf("%0.5f %0.5f\n", O.x, O.y);
Advertisement
Add Comment
Please, Sign In to add comment