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