test_math.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. /*************************************************************************/
  2. /* test_math.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "test_math.h"
  31. #include "core/math/basis.h"
  32. #include "core/math/camera_matrix.h"
  33. #include "core/math/delaunay_3d.h"
  34. #include "core/math/math_funcs.h"
  35. #include "core/math/transform.h"
  36. #include "core/method_ptrcall.h"
  37. #include "core/os/file_access.h"
  38. #include "core/os/keyboard.h"
  39. #include "core/os/os.h"
  40. #include "core/print_string.h"
  41. #include "core/ustring.h"
  42. #include "core/variant.h"
  43. #include "core/vmap.h"
  44. #include "scene/main/node.h"
  45. #include "scene/resources/texture.h"
  46. #include "servers/rendering/shader_language.h"
  47. namespace TestMath {
  48. class GetClassAndNamespace {
  49. String code;
  50. int idx;
  51. int line;
  52. String error_str;
  53. bool error;
  54. Variant value;
  55. String class_name;
  56. enum Token {
  57. TK_BRACKET_OPEN,
  58. TK_BRACKET_CLOSE,
  59. TK_CURLY_BRACKET_OPEN,
  60. TK_CURLY_BRACKET_CLOSE,
  61. TK_PERIOD,
  62. TK_COLON,
  63. TK_COMMA,
  64. TK_SYMBOL,
  65. TK_IDENTIFIER,
  66. TK_STRING,
  67. TK_NUMBER,
  68. TK_EOF,
  69. TK_ERROR
  70. };
  71. Token get_token() {
  72. while (true) {
  73. switch (code[idx]) {
  74. case '\n': {
  75. line++;
  76. idx++;
  77. break;
  78. };
  79. case 0: {
  80. return TK_EOF;
  81. } break;
  82. case '{': {
  83. idx++;
  84. return TK_CURLY_BRACKET_OPEN;
  85. };
  86. case '}': {
  87. idx++;
  88. return TK_CURLY_BRACKET_CLOSE;
  89. };
  90. case '[': {
  91. idx++;
  92. return TK_BRACKET_OPEN;
  93. };
  94. case ']': {
  95. idx++;
  96. return TK_BRACKET_CLOSE;
  97. };
  98. case ':': {
  99. idx++;
  100. return TK_COLON;
  101. };
  102. case ',': {
  103. idx++;
  104. return TK_COMMA;
  105. };
  106. case '.': {
  107. idx++;
  108. return TK_PERIOD;
  109. };
  110. case '#': {
  111. //compiler directive
  112. while (code[idx] != '\n' && code[idx] != 0) {
  113. idx++;
  114. }
  115. continue;
  116. } break;
  117. case '/': {
  118. switch (code[idx + 1]) {
  119. case '*': { // block comment
  120. idx += 2;
  121. while (true) {
  122. if (code[idx] == 0) {
  123. error_str = "Unterminated comment";
  124. error = true;
  125. return TK_ERROR;
  126. } else if (code[idx] == '*' && code[idx + 1] == '/') {
  127. idx += 2;
  128. break;
  129. } else if (code[idx] == '\n') {
  130. line++;
  131. }
  132. idx++;
  133. }
  134. } break;
  135. case '/': { // line comment skip
  136. while (code[idx] != '\n' && code[idx] != 0) {
  137. idx++;
  138. }
  139. } break;
  140. default: {
  141. value = "/";
  142. idx++;
  143. return TK_SYMBOL;
  144. }
  145. }
  146. continue; // a comment
  147. } break;
  148. case '\'':
  149. case '"': {
  150. CharType begin_str = code[idx];
  151. idx++;
  152. String tk_string = String();
  153. while (true) {
  154. if (code[idx] == 0) {
  155. error_str = "Unterminated String";
  156. error = true;
  157. return TK_ERROR;
  158. } else if (code[idx] == begin_str) {
  159. idx++;
  160. break;
  161. } else if (code[idx] == '\\') {
  162. //escaped characters...
  163. idx++;
  164. CharType next = code[idx];
  165. if (next == 0) {
  166. error_str = "Unterminated String";
  167. error = true;
  168. return TK_ERROR;
  169. }
  170. CharType res = 0;
  171. switch (next) {
  172. case 'b':
  173. res = 8;
  174. break;
  175. case 't':
  176. res = 9;
  177. break;
  178. case 'n':
  179. res = 10;
  180. break;
  181. case 'f':
  182. res = 12;
  183. break;
  184. case 'r':
  185. res = 13;
  186. break;
  187. case '\"':
  188. res = '\"';
  189. break;
  190. case '\\':
  191. res = '\\';
  192. break;
  193. default: {
  194. res = next;
  195. } break;
  196. }
  197. tk_string += res;
  198. } else {
  199. if (code[idx] == '\n') {
  200. line++;
  201. }
  202. tk_string += code[idx];
  203. }
  204. idx++;
  205. }
  206. value = tk_string;
  207. return TK_STRING;
  208. } break;
  209. default: {
  210. if (code[idx] <= 32) {
  211. idx++;
  212. break;
  213. }
  214. if ((code[idx] >= 33 && code[idx] <= 47) || (code[idx] >= 58 && code[idx] <= 64) || (code[idx] >= 91 && code[idx] <= 96) || (code[idx] >= 123 && code[idx] <= 127)) {
  215. value = String::chr(code[idx]);
  216. idx++;
  217. return TK_SYMBOL;
  218. }
  219. if (code[idx] == '-' || (code[idx] >= '0' && code[idx] <= '9')) {
  220. //a number
  221. const CharType *rptr;
  222. double number = String::to_double(&code[idx], &rptr);
  223. idx += (rptr - &code[idx]);
  224. value = number;
  225. return TK_NUMBER;
  226. } else if ((code[idx] >= 'A' && code[idx] <= 'Z') || (code[idx] >= 'a' && code[idx] <= 'z') || code[idx] > 127) {
  227. String id;
  228. while ((code[idx] >= 'A' && code[idx] <= 'Z') || (code[idx] >= 'a' && code[idx] <= 'z') || code[idx] > 127) {
  229. id += code[idx];
  230. idx++;
  231. }
  232. value = id;
  233. return TK_IDENTIFIER;
  234. } else {
  235. error_str = "Unexpected character.";
  236. error = true;
  237. return TK_ERROR;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. public:
  244. Error parse(const String &p_code, const String &p_known_class_name = String()) {
  245. code = p_code;
  246. idx = 0;
  247. line = 0;
  248. error_str = String();
  249. error = false;
  250. value = Variant();
  251. class_name = String();
  252. bool use_next_class = false;
  253. Token tk = get_token();
  254. Map<int, String> namespace_stack;
  255. int curly_stack = 0;
  256. while (!error || tk != TK_EOF) {
  257. if (tk == TK_BRACKET_OPEN) {
  258. tk = get_token();
  259. if (tk == TK_IDENTIFIER && String(value) == "ScriptClass") {
  260. if (get_token() == TK_BRACKET_CLOSE) {
  261. use_next_class = true;
  262. }
  263. }
  264. } else if (tk == TK_IDENTIFIER && String(value) == "class") {
  265. tk = get_token();
  266. if (tk == TK_IDENTIFIER) {
  267. String name = value;
  268. if (use_next_class || p_known_class_name == name) {
  269. for (Map<int, String>::Element *E = namespace_stack.front(); E; E = E->next()) {
  270. class_name += E->get() + ".";
  271. }
  272. class_name += String(value);
  273. break;
  274. }
  275. }
  276. } else if (tk == TK_IDENTIFIER && String(value) == "namespace") {
  277. String name;
  278. int at_level = curly_stack;
  279. while (true) {
  280. tk = get_token();
  281. if (tk == TK_IDENTIFIER) {
  282. name += String(value);
  283. }
  284. tk = get_token();
  285. if (tk == TK_PERIOD) {
  286. name += ".";
  287. } else if (tk == TK_CURLY_BRACKET_OPEN) {
  288. curly_stack++;
  289. break;
  290. } else {
  291. break; //whathever else
  292. }
  293. }
  294. if (name != String()) {
  295. namespace_stack[at_level] = name;
  296. }
  297. } else if (tk == TK_CURLY_BRACKET_OPEN) {
  298. curly_stack++;
  299. } else if (tk == TK_CURLY_BRACKET_CLOSE) {
  300. curly_stack--;
  301. if (namespace_stack.has(curly_stack)) {
  302. namespace_stack.erase(curly_stack);
  303. }
  304. }
  305. tk = get_token();
  306. }
  307. if (error) {
  308. return ERR_PARSE_ERROR;
  309. }
  310. return OK;
  311. }
  312. String get_error() {
  313. return error_str;
  314. }
  315. String get_class() {
  316. return class_name;
  317. }
  318. };
  319. void test_vec(Plane p_vec) {
  320. CameraMatrix cm;
  321. cm.set_perspective(45, 1, 0, 100);
  322. Plane v0 = cm.xform4(p_vec);
  323. print_line("out: " + v0);
  324. v0.normal.z = (v0.d / 100.0 * 2.0 - 1.0) * v0.d;
  325. print_line("out_F: " + v0);
  326. }
  327. uint32_t ihash(uint32_t a) {
  328. a = (a + 0x7ed55d16) + (a << 12);
  329. a = (a ^ 0xc761c23c) ^ (a >> 19);
  330. a = (a + 0x165667b1) + (a << 5);
  331. a = (a + 0xd3a2646c) ^ (a << 9);
  332. a = (a + 0xfd7046c5) + (a << 3);
  333. a = (a ^ 0xb55a4f09) ^ (a >> 16);
  334. return a;
  335. }
  336. uint32_t ihash2(uint32_t a) {
  337. a = (a ^ 61) ^ (a >> 16);
  338. a = a + (a << 3);
  339. a = a ^ (a >> 4);
  340. a = a * 0x27d4eb2d;
  341. a = a ^ (a >> 15);
  342. return a;
  343. }
  344. uint32_t ihash3(uint32_t a) {
  345. a = (a + 0x479ab41d) + (a << 8);
  346. a = (a ^ 0xe4aa10ce) ^ (a >> 5);
  347. a = (a + 0x9942f0a6) - (a << 14);
  348. a = (a ^ 0x5aedd67d) ^ (a >> 3);
  349. a = (a + 0x17bea992) + (a << 7);
  350. return a;
  351. }
  352. MainLoop *test() {
  353. {
  354. Vector<Vector3> points;
  355. points.push_back(Vector3(0, 0, 0));
  356. points.push_back(Vector3(0, 0, 1));
  357. points.push_back(Vector3(0, 1, 0));
  358. points.push_back(Vector3(0, 1, 1));
  359. points.push_back(Vector3(1, 1, 0));
  360. points.push_back(Vector3(1, 0, 0));
  361. points.push_back(Vector3(1, 0, 1));
  362. points.push_back(Vector3(1, 1, 1));
  363. for (int i = 0; i < 800; i++) {
  364. points.push_back(Vector3(Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0) * Vector3(25, 30, 33));
  365. }
  366. Vector<Delaunay3D::OutputSimplex> os = Delaunay3D::tetrahedralize(points);
  367. print_line("simplices in the end: " + itos(os.size()));
  368. for (int i = 0; i < os.size(); i++) {
  369. print_line("Simplex " + itos(i) + ": ");
  370. print_line(points[os[i].points[0]]);
  371. print_line(points[os[i].points[1]]);
  372. print_line(points[os[i].points[2]]);
  373. print_line(points[os[i].points[3]]);
  374. }
  375. {
  376. FileAccessRef f = FileAccess::open("res://bsp.obj", FileAccess::WRITE);
  377. for (int i = 0; i < os.size(); i++) {
  378. f->store_line("o Simplex" + itos(i));
  379. for (int j = 0; j < 4; j++) {
  380. f->store_line(vformat("v %f %f %f", points[os[i].points[j]].x, points[os[i].points[j]].y, points[os[i].points[j]].z));
  381. }
  382. static const int face_order[4][3] = {
  383. { 1, 2, 3 },
  384. { 1, 3, 4 },
  385. { 1, 2, 4 },
  386. { 2, 3, 4 }
  387. };
  388. for (int j = 0; j < 4; j++) {
  389. f->store_line(vformat("f %d %d %d", 4 * i + face_order[j][0], 4 * i + face_order[j][1], 4 * i + face_order[j][2]));
  390. }
  391. }
  392. f->close();
  393. }
  394. return nullptr;
  395. }
  396. {
  397. float r = 1;
  398. float g = 0.5;
  399. float b = 0.1;
  400. const float pow2to9 = 512.0f;
  401. const float B = 15.0f;
  402. const float N = 9.0f;
  403. float sharedexp = 65408.000f;
  404. float cRed = MAX(0.0f, MIN(sharedexp, r));
  405. float cGreen = MAX(0.0f, MIN(sharedexp, g));
  406. float cBlue = MAX(0.0f, MIN(sharedexp, b));
  407. float cMax = MAX(cRed, MAX(cGreen, cBlue));
  408. float expp = MAX(-B - 1.0f, floor(Math::log(cMax) / Math_LN2)) + 1.0f + B;
  409. float sMax = (float)floor((cMax / Math::pow(2.0f, expp - B - N)) + 0.5f);
  410. float exps = expp + 1.0f;
  411. if (0.0 <= sMax && sMax < pow2to9) {
  412. exps = expp;
  413. }
  414. float sRed = Math::floor((cRed / pow(2.0f, exps - B - N)) + 0.5f);
  415. float sGreen = Math::floor((cGreen / pow(2.0f, exps - B - N)) + 0.5f);
  416. float sBlue = Math::floor((cBlue / pow(2.0f, exps - B - N)) + 0.5f);
  417. print_line("R: " + rtos(sRed) + " G: " + rtos(sGreen) + " B: " + rtos(sBlue) + " EXP: " + rtos(exps));
  418. uint32_t rgbe = (Math::fast_ftoi(sRed) & 0x1FF) | ((Math::fast_ftoi(sGreen) & 0x1FF) << 9) | ((Math::fast_ftoi(sBlue) & 0x1FF) << 18) | ((Math::fast_ftoi(exps) & 0x1F) << 27);
  419. float rb = rgbe & 0x1ff;
  420. float gb = (rgbe >> 9) & 0x1ff;
  421. float bb = (rgbe >> 18) & 0x1ff;
  422. float eb = (rgbe >> 27);
  423. float mb = Math::pow(2.0, eb - 15.0 - 9.0);
  424. float rd = rb * mb;
  425. float gd = gb * mb;
  426. float bd = bb * mb;
  427. print_line("RGBE: " + Color(rd, gd, bd));
  428. }
  429. Vector<int> ints;
  430. ints.resize(20);
  431. {
  432. int *w;
  433. w = ints.ptrw();
  434. for (int i = 0; i < ints.size(); i++) {
  435. w[i] = i;
  436. }
  437. }
  438. Vector<int> posho = ints;
  439. {
  440. const int *r = posho.ptr();
  441. for (int i = 0; i < posho.size(); i++) {
  442. print_line(itos(i) + " : " + itos(r[i]));
  443. }
  444. }
  445. List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
  446. if (cmdlargs.empty()) {
  447. //try editor!
  448. return nullptr;
  449. }
  450. String test = cmdlargs.back()->get();
  451. if (test == "math") {
  452. // Not a file name but the test name, abort.
  453. // FIXME: This test is ugly as heck, needs fixing :)
  454. return nullptr;
  455. }
  456. FileAccess *fa = FileAccess::open(test, FileAccess::READ);
  457. ERR_FAIL_COND_V_MSG(!fa, nullptr, "Could not open file: " + test);
  458. Vector<uint8_t> buf;
  459. int flen = fa->get_len();
  460. buf.resize(fa->get_len() + 1);
  461. fa->get_buffer(buf.ptrw(), flen);
  462. buf.write[flen] = 0;
  463. String code;
  464. code.parse_utf8((const char *)&buf[0]);
  465. GetClassAndNamespace getclass;
  466. if (getclass.parse(code)) {
  467. print_line("Parse error: " + getclass.get_error());
  468. } else {
  469. print_line("Found class: " + getclass.get_class());
  470. }
  471. {
  472. Vector<int> hashes;
  473. List<StringName> tl;
  474. ClassDB::get_class_list(&tl);
  475. for (List<StringName>::Element *E = tl.front(); E; E = E->next()) {
  476. Vector<uint8_t> m5b = E->get().operator String().md5_buffer();
  477. hashes.push_back(hashes.size());
  478. }
  479. for (int i = nearest_shift(hashes.size()); i < 20; i++) {
  480. bool success = true;
  481. for (int s = 0; s < 10000; s++) {
  482. Set<uint32_t> existing;
  483. success = true;
  484. for (int j = 0; j < hashes.size(); j++) {
  485. uint32_t eh = ihash2(ihash3(hashes[j] + ihash(s) + s)) & ((1 << i) - 1);
  486. if (existing.has(eh)) {
  487. success = false;
  488. break;
  489. }
  490. existing.insert(eh);
  491. }
  492. if (success) {
  493. print_line("success at " + itos(i) + "/" + itos(nearest_shift(hashes.size())) + " shift " + itos(s));
  494. break;
  495. }
  496. }
  497. if (success) {
  498. break;
  499. }
  500. }
  501. print_line("DONE");
  502. }
  503. {
  504. print_line("NUM: " + itos(-128));
  505. }
  506. {
  507. Vector3 v(1, 2, 3);
  508. v.normalize();
  509. float a = 0.3;
  510. Basis m(v, a);
  511. Vector3 v2(7, 3, 1);
  512. v2.normalize();
  513. float a2 = 0.8;
  514. Basis m2(v2, a2);
  515. Quat q = m;
  516. Quat q2 = m2;
  517. Basis m3 = m.inverse() * m2;
  518. Quat q3 = (q.inverse() * q2); //.normalized();
  519. print_line(Quat(m3));
  520. print_line(q3);
  521. print_line("before v: " + v + " a: " + rtos(a));
  522. q.get_axis_angle(v, a);
  523. print_line("after v: " + v + " a: " + rtos(a));
  524. }
  525. String ret;
  526. List<String> args;
  527. args.push_back("-l");
  528. Error err = OS::get_singleton()->execute("/bin/ls", args, true, nullptr, &ret);
  529. print_line("error: " + itos(err));
  530. print_line(ret);
  531. Basis m3;
  532. m3.rotate(Vector3(1, 0, 0), 0.2);
  533. m3.rotate(Vector3(0, 1, 0), 1.77);
  534. m3.rotate(Vector3(0, 0, 1), 212);
  535. Basis m32;
  536. m32.set_euler(m3.get_euler());
  537. print_line("ELEULEEEEEEEEEEEEEEEEEER: " + m3.get_euler() + " vs " + m32.get_euler());
  538. {
  539. Dictionary d;
  540. d["momo"] = 1;
  541. Dictionary b = d;
  542. b["44"] = 4;
  543. }
  544. print_line("inters: " + rtos(Geometry::segment_intersects_circle(Vector2(-5, 0), Vector2(-2, 0), Vector2(), 1.0)));
  545. print_line("cross: " + Vector3(1, 2, 3).cross(Vector3(4, 5, 7)));
  546. print_line("dot: " + rtos(Vector3(1, 2, 3).dot(Vector3(4, 5, 7))));
  547. print_line("abs: " + Vector3(-1, 2, -3).abs());
  548. print_line("distance_to: " + rtos(Vector3(1, 2, 3).distance_to(Vector3(4, 5, 7))));
  549. print_line("distance_squared_to: " + rtos(Vector3(1, 2, 3).distance_squared_to(Vector3(4, 5, 7))));
  550. print_line("plus: " + (Vector3(1, 2, 3) + Vector3(Vector3(4, 5, 7))));
  551. print_line("minus: " + (Vector3(1, 2, 3) - Vector3(Vector3(4, 5, 7))));
  552. print_line("mul: " + (Vector3(1, 2, 3) * Vector3(Vector3(4, 5, 7))));
  553. print_line("div: " + (Vector3(1, 2, 3) / Vector3(Vector3(4, 5, 7))));
  554. print_line("mul scalar: " + (Vector3(1, 2, 3) * 2.0));
  555. print_line("premul scalar: " + (2.0 * Vector3(1, 2, 3)));
  556. print_line("div scalar: " + (Vector3(1, 2, 3) / 3.0));
  557. print_line("length: " + rtos(Vector3(1, 2, 3).length()));
  558. print_line("length squared: " + rtos(Vector3(1, 2, 3).length_squared()));
  559. print_line("normalized: " + Vector3(1, 2, 3).normalized());
  560. print_line("inverse: " + Vector3(1, 2, 3).inverse());
  561. {
  562. Vector3 v(4, 5, 7);
  563. v.normalize();
  564. print_line("normalize: " + v);
  565. }
  566. {
  567. Vector3 v(4, 5, 7);
  568. v += Vector3(1, 2, 3);
  569. print_line("+=: " + v);
  570. }
  571. {
  572. Vector3 v(4, 5, 7);
  573. v -= Vector3(1, 2, 3);
  574. print_line("-=: " + v);
  575. }
  576. {
  577. Vector3 v(4, 5, 7);
  578. v *= Vector3(1, 2, 3);
  579. print_line("*=: " + v);
  580. }
  581. {
  582. Vector3 v(4, 5, 7);
  583. v /= Vector3(1, 2, 3);
  584. print_line("/=: " + v);
  585. }
  586. {
  587. Vector3 v(4, 5, 7);
  588. v *= 2.0;
  589. print_line("scalar *=: " + v);
  590. }
  591. {
  592. Vector3 v(4, 5, 7);
  593. v /= 2.0;
  594. print_line("scalar /=: " + v);
  595. }
  596. return nullptr;
  597. }
  598. } // namespace TestMath