SHARE
TWEET

Untitled

a guest Mar 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Runtime(
  2.  
  3. )
  4. {
  5.  
  6.     console.log("Running");
  7. }
  8.  
  9. function initViewPort(
  10.     width,
  11.     height
  12. )
  13. {
  14.     var viewport = $("#viewport");
  15.     for (var i = 0; i < 500; i++) {
  16.         viewport.append("<div class='pixel'></div>");
  17.     }
  18. }
  19. initViewPort(100,200)
  20. // Geometry
  21. function GetSquareArea(length)
  22. {
  23.  
  24.     return length * length;
  25. }
  26.  
  27. function GetRectangleArea(
  28.  
  29.     width,
  30.     height
  31. )
  32. {
  33.     return width * height;
  34. }
  35.  
  36. function GetRectTriangleArea(
  37.     width,
  38.     height
  39. )
  40. {
  41.     return width * height / 2;
  42. }
  43. // ENnd of Geometry
  44.  
  45. function PopulateLimitDataSet(
  46.     limit
  47. )
  48. {
  49.  
  50.     var limitsData = [];
  51.     var upScaleLimitTracker = limit;
  52.     var downScaleLimitTracker = limit;
  53.  
  54.     // Generate the down limits sets
  55.     for (var i = 0; i < 10; i++) {
  56.         upScaleLimitTracker += 0.0001;
  57.         limitsData.push(upScaleLimitTracker);
  58.     }
  59.  
  60.     // Generate the down limits sets
  61.     for (var i = 0; i < 10; i++) {
  62.         downScaleLimitTracker -= 0.0001;
  63.         limitsData.push(downScaleLimitTracker);
  64.     }
  65.  
  66.     return limitsData;
  67. }
  68.  
  69.  
  70.  
  71. function cartesian2Polar(x,
  72.     y)
  73. {
  74.     distance = Math.sqrt(x*x + y*y)
  75.     radians = Math.atan2(y,x) //This takes y first
  76.     polarCoor = { distance:distance, radians:radians }
  77.  
  78.     return polarCoor
  79. }
  80.  
  81. // Returns either or not the two point are rationnal
  82. function IsRationnal(
  83.  
  84.     PointA,
  85.     PointB
  86. )
  87. {
  88. // From proof of: p/(−q) = (−p)/q, (−p)/(−q) = p/q.
  89.     var p = PointA;
  90.     var q = PointB;
  91.  
  92.  
  93.     // Define two items to compare proof A
  94.     var ProofANumber1 = p / ToNegativeNumber(q);
  95.     var ProofANumber2 = ToNegativeNumber(p) / q;
  96.  
  97.  
  98.     // Define two items to compare proof B
  99.     var ProofBNumber1 = ToNegativeNumber(p)/ToNegativeNumber(q);
  100.     var ProofBNumber2 = p/q;
  101.  
  102.     if (ProofANumber1 == ProofANumber2
  103.         &&
  104.         ProofBNumber1 == ProofBNumber2) {
  105.         return true;
  106.     } else {
  107.         return false;
  108.     }
  109. }
  110.  
  111.  
  112. // Is commutative
  113. function IsValidLine3(
  114.     a,
  115.     b,
  116.     c
  117. ){
  118.     if( a + b == b + a &&
  119.         a + (b + c) == (a + b) + c &&
  120.         a * b == b * a &&
  121.         a * (b + c) ==  (a * b) * c
  122.     ) {
  123.         return true;
  124.     } else
  125.     {
  126.         return false;
  127.     }
  128.  
  129. }
  130.  
  131.  
  132. function InitVector3(
  133.     x,
  134.     y,
  135.     z
  136. )
  137. {
  138.     var Vector3 = {};
  139.     Vector3.x = x;
  140.     Vector3.y = y;
  141.     Vector3.z = z;
  142.     return Vector3;
  143. }
  144.  
  145. function InitVector3AtOrigin(
  146. )
  147. {
  148.     var Vector3 = {};
  149.     Vector3.x = 0;
  150.     Vector3.y = 0;
  151.     Vector3.z = 0;
  152.     return Vector3;
  153. }
  154.  
  155. function InitHomogeneousVectorAtOrigin()
  156. {
  157.     var HomogeneousPoint = {};
  158.     HomogeneousPoint.x = 0;
  159.     HomogeneousPoint.y = 0;
  160.     HomogeneousPoint.z = 0;
  161.     HomogeneousPoint.w = 0;
  162.  
  163.     return HomogeneousPoint;
  164. }
  165.  
  166. function InitHomogeneousVectorAtCoordinate(
  167.     x,
  168.     y,
  169.     z,
  170.     w
  171. )
  172. {
  173.     var HomogeneousPoint = {};
  174.     HomogeneousPoint.x = x;
  175.     HomogeneousPoint.y = y;
  176.     HomogeneousPoint.z = z;
  177.     HomogeneousPoint.w = w;
  178.  
  179.     return HomogeneousPoint;
  180. }
  181.  
  182. //||V||=x+V.y∗V.y+V.z∗V.z−−−−−−−−−−−−−−−−−−−−−−−−−−−−√
  183. function FindVectorLength(
  184.     Vector
  185. )
  186. {
  187.     var length = Math.sqrt(Vector.x * Vector.x + Vector.x * Vector.y + Vector.y * Vector.z )
  188.     return length;
  189. }
  190.  
  191. function NormalizeVector(
  192.     Vector,
  193.     NormalVal
  194. )
  195. {
  196.     var length = Math.sqrt(Vector.x * Vector.x + Vector.x * Vector.y + Vector.y * Vector.z )
  197.  
  198.     var inverseLength = NormalVal / length;
  199.     x *= inverseLength
  200.     y *= inverseLength
  201.     z *= inverseLength
  202.  
  203.     return Vector;
  204.  
  205. }
  206.  
  207. function DotProductVector(
  208.     VectorA,
  209.     VectorB
  210. )
  211. {
  212.     var NewVector = {};
  213.     NewVector.x = (VectorA.x * VectorB.x);
  214.     NewVector.y = (VectorA.y * VectorB.y);
  215.     NewVector.z = (VectorA.z * VectorB.z);
  216.     // var DotProduct =  + (VectorA.y * VectorB.y) + (VectorA.z * VectorB.z);
  217.  
  218.     return NewVector;
  219. }
  220.  
  221.  
  222. function CrossProduct(
  223.     VectorA,
  224.     VectorB
  225. )
  226. {
  227.     /*
  228.     CX =AY∗BZ−AZ∗BY
  229.     CY =AZ∗BX−AX∗BZ
  230.     CZ =AX∗BY−AY∗BX
  231.     */
  232.  
  233.     /*
  234.  
  235.     */
  236.     var NewVector = {};
  237.     NewVector.x = (VectorA.y * VectorB.z) - (VectorA.z * VectorB.y);
  238.     NewVector.y = (VectorA.z * VectorB.x) - (VectorA.x * VectorB.z);
  239.     NewVector.z = (VectorA.x * VectorB.y) - (VectorA.y * VectorB.x);;
  240.     // var DotProduct =  + (VectorA.y * VectorB.y) + (VectorA.z * VectorB.z);
  241.  
  242.     return NewVector;
  243. }
  244.  
  245.  
  246. // Matrices
  247. function InitMatrix(
  248.     sizeCol,
  249.     sizeRow
  250. )
  251. {
  252.     const matrix = new Array(sizeRow).fill(0).map(() => new Array(sizeRow).fill(0));
  253.     return matrix;
  254. }
  255.  
  256. function MultiplyMatrices4(
  257.     MatriceA,
  258.     MatriceB
  259. )
  260. {
  261.     var MultMatrix = new Array(4).fill(0).map(() => new Array(4).fill(0));
  262.  
  263.     for (var  i = 0; i < 4; ++i) {
  264.         for (var j = 0; j < 4; ++j) {
  265.             MultMatrix[i][j] =
  266.                          MatriceA[i][0] * MatriceB[0][j] +
  267.                          MatriceA[i][1] * MatriceB[1][j] +
  268.                          MatriceA[i][2] * MatriceB[2][j] +
  269.                          MatriceA[i][3] * MatriceB[3][j];
  270.         }
  271.     }
  272.  
  273.     return MultMatrix;
  274. }
  275.  
  276. function GenerateRandomDataMatrix(
  277.  
  278.         sizeCol,
  279.         sizeRow,
  280.         min,
  281.         max
  282. )
  283. {
  284.     var RandomDataMatrix = new Array(sizeCol).fill(0).map(() => new Array(sizeCol).fill(0));
  285.  
  286.     for (var  i = 0; i < sizeCol; ++i) {
  287.         for (var j = 0; j < sizeRow; ++j) {
  288.             RandomDataMatrix[i][j] = Math.floor(Math.random() * (+max - +min)) + +min;
  289.         }
  290.     }
  291.     return RandomDataMatrix;
  292.  
  293. }
  294. var newRandomData = GenerateRandomDataMatrix(10,15, 10, 2500);
  295. console.log(newRandomData);
  296. var MatricesTest = InitMatrix(5,5);
  297. console.log(MatricesTest);
  298. var v = InitVector3(3,4,5);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top