Dot product: Difference between revisions
Content deleted Content added
→{{header|Wren}}: Added a library based version. |
|||
Line 3,525: | Line 3,525: | ||
<pre> |
<pre> |
||
The dot product of [1, 3, -5] and [4, -2, -1] is 3. |
The dot product of [1, 3, -5] and [4, -2, -1] is 3. |
||
</pre> |
|||
{{libheader|Wren-vector}} |
|||
Alternatively, using the above module: |
|||
<syntaxhighlight lang="ecmascript">import "./vector" for Vector3 |
|||
var v1 = Vector3.new(1, 3, -5) |
|||
var v2 = Vector3.new(4, -2, -1) |
|||
System.print("The dot product of %(v1) and %(v2) is %(v1.dot(v2)).")</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
The dot product of (1, 3, -5) and (4, -2, -1) is 3. |
|||
</pre> |
</pre> |
||