Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double rayX = (fromY - toY);
- double rayY = (toX - fromX);
- double rayC = ((fromX * toY) - (toX * fromY)); //общо уравнение на лъча
- for (int c = 0; c < input[9]; c++)
- {
- for (int i = 10; i < input[10] + 10; i++)
- {
- double mirrorX = input[i + 2] - input[i + 4];
- double mirrorY = input[i + 3] - input[i + 1];
- double mirrorC = (input[i + 1] * input[i + 4]) - (input[i + 3] * input[i + 2]);
- if(pointsOfCollision(rayX, rayY, rayC, mirrorX, mirrorY, mirrorC,
- collisionPointX, collisionPointY));
- {
- double heightX = -mirrorY;
- double heightY = mirrorX;
- double heightC = -(heightX * collisionPointX + heightY * collisionPointY);
- double parallelX = mirrorX;
- double parallelY = mirrorY;
- double parallelC = -(fromX * parallelX + fromY * parallelY);
- double deltaProjected = heightX * parallelY - heightY * parallelX;
- double projectedX = (heightC * parallelY - heightY * parallelC) / deltaProjected;
- double projectedY = (heightX * parallelC - heightC - parallelY) / deltaProjected;
- double secondPointX = projectedX * 2 - fromX;
- double secondPointY = projectedY * 2 - fromY;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement