Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- struct Point
- {
- int x, y;
- };
- struct ScreenInfo
- {
- int screenWidth;
- int screenHeight;
- int xMin, xMax, yMin, yMax;
- };
- Point mat2screen(const Point& mcoord, const ScreenInfo& info);
- int main()
- {
- ScreenInfo info = { 800, 600, -5, 5, -4, 4 };
- Point pm ={ 0, 0 };
- Point pe;
- pe = mat2screen(pm, info);
- std::cout << pe.x << pe.y << std::endl;
- }
- Point mat2screen(const Point& mcoord, const ScreenInfo& info)
- {
- Point rv; //pukt ukladu ekranowego
- rv.x = info.screenWidth / (info.xMax - info.xMin) * mcoord.x + info.screenWidth * info.xMin / (info.xMin - info.xMax);
- rv.y = info.screenHeight / (info.yMin - info.yMax) * mcoord.y + info.screenHeight * info.yMax / (info.yMax - info.yMin);
- return rv;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement