Advertisement
Wojtekd

Oswietlenie

Jan 13th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. // slonce
  2. var sun = new Vector3(1, 1, -1);
  3.  
  4. float OkreslJasnosc( Vector3 A, Vector3 B, Vector3 C )
  5. {    
  6.     // 1. okreslamy wektor normalny plaszczyzny trojkata:
  7.     e1 = A - B;
  8.     e2 = A - C;
  9.     var normal = CrossProduct( e1, e2 );
  10.  
  11.     // 2. przed zmierzeniem kata trzeba oba wektory znormalizowac:
  12.     sun.normalize();
  13.     normal.normalize();
  14.  
  15.     // 3. kat pomiedzy wektorami s i n (odrazu z zamiana na stopnie):  
  16.     var katPomiedzy = Math.Acos( DotProduct(sun, normal) )  * 180 / Math.PI;
  17.  
  18.     // 4. zwroc jasnosc procentowo:
  19.     var jasnosc = ( katPomiedzy / 180 ) * 100;
  20.     return jasnosc;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement