Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. double rayX = (fromY - toY);
  2.     double rayY = (toX - fromX);
  3.     double rayC = ((fromX * toY) - (toX * fromY)); //общо уравнение на лъча
  4.  
  5.     for (int c = 0;  c < input[9]; c++)
  6.     {
  7.         for (int i = 10; i < input[10] + 10; i++)
  8.         {
  9.             double mirrorX = input[i + 2] - input[i + 4];
  10.             double mirrorY = input[i + 3] - input[i + 1];
  11.             double mirrorC = (input[i + 1] * input[i + 4]) - (input[i + 3] * input[i + 2]);
  12.  
  13.             if(pointsOfCollision(rayX, rayY, rayC, mirrorX, mirrorY, mirrorC,
  14.                 collisionPointX, collisionPointY));
  15.             {
  16.                 double heightX = -mirrorY;
  17.                 double heightY = mirrorX;
  18.                 double heightC = -(heightX * collisionPointX + heightY * collisionPointY);
  19.  
  20.                 double parallelX = mirrorX;
  21.                 double parallelY = mirrorY;
  22.                 double parallelC = -(fromX * parallelX + fromY * parallelY);
  23.  
  24.                 double deltaProjected = heightX * parallelY - heightY * parallelX;
  25.                 double projectedX = (heightC * parallelY - heightY * parallelC) / deltaProjected;
  26.                 double projectedY = (heightX * parallelC - heightC - parallelY) / deltaProjected;
  27.  
  28.                 double secondPointX = projectedX * 2 - fromX;
  29.                 double secondPointY = projectedY * 2 - fromY;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement