victor实现2D向量加减乘除距离等运算示例代码
代码语言:html
所属分类:其他
代码描述:victor实现2D向量加减乘除距离等运算示例代码
代码标签: victor 2D 向量 加减 乘除 距离 运算 示例 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Victor.js Demo</title> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/victor.1.1.0.js"></script> <style> #console { white-space: pre; background-color: #f5f5f5; padding: 10px; margin-top: 20px; border: 1px solid #ccc; height: 300px; overflow-y: auto; } </style> </head> <body> <h2>Victor.js Demo</h2> <button onclick="runDemo()">Run Demo</button> <pre id="console"></pre> <script> function runDemo() { console.clear(); const v1 = new Victor(42, 1337); const v2 = new Victor(100, 200); console.log('v1:', v1.toString()); console.log('v2:', v2.toString()); // Clone const v1Clone = v1.clone(); console.log('v1 Clone:', v1Clone.toString()); // Add const vAdd = v1.add(v2); console.log('v1 + v2:', vAdd.toString()); // Subtract const vSubtract = v1.subtract(v2); console.log('v1 - v2:', vSubtract.toString()); // Multiply const vMultiply = v1.multiply(v2); console.log('v1 * v2:', vMultiply.toString()); // Divide const vDivide = v1.........完整代码请登录后点击上方下载按钮下载查看
网友评论0