ludic/ns-vector.html
2026-09-17 22:10:03 +00:00

22 lines
No EOL
4 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Vector — Ludic</title>
<meta name="description" content="2D vector math for positions, velocities, and directions.">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
<main class="wrap item">
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Vector</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Vector</h1></div>
<p class="ns-blurb">2D vector math for positions, velocities, and directions. A <code>Vector</code> is a pair of Q16.16 fixed components packed into one value, so it is copied by value and never allocates. Every operation is deterministic integer fixed-point — bit-identical on every platform, the same guarantee the rest of the runtime gives. Arguments are positional; angles are in radians.</p>
<div class="ns-methods"><a class="ns-method" href="vector-make.html"><code class="nm-sig">Vector.make(x, y) -&gt; Vector</code><span class="nm-tip">Build a vector from x and y components.</span></a><a class="ns-method" href="vector-zero.html"><code class="nm-sig">Vector.zero() -&gt; Vector</code><span class="nm-tip">The zero vector, (0, 0).</span></a><a class="ns-method" href="vector-x.html"><code class="nm-sig">Vector.x(v) -&gt; fixed</code><span class="nm-tip">The x component of a vector.</span></a><a class="ns-method" href="vector-y.html"><code class="nm-sig">Vector.y(v) -&gt; fixed</code><span class="nm-tip">The y component of a vector.</span></a><a class="ns-method" href="vector-add.html"><code class="nm-sig">Vector.add(a, b) -&gt; Vector</code><span class="nm-tip">Component-wise sum a + b.</span></a><a class="ns-method" href="vector-sub.html"><code class="nm-sig">Vector.sub(a, b) -&gt; Vector</code><span class="nm-tip">Component-wise difference a - b.</span></a><a class="ns-method" href="vector-scale.html"><code class="nm-sig">Vector.scale(v, s) -&gt; Vector</code><span class="nm-tip">Scale a vector by a scalar.</span></a><a class="ns-method" href="vector-dot.html"><code class="nm-sig">Vector.dot(a, b) -&gt; fixed</code><span class="nm-tip">The dot product of two vectors.</span></a><a class="ns-method" href="vector-length.html"><code class="nm-sig">Vector.length(v) -&gt; fixed</code><span class="nm-tip">The length (magnitude) of a vector.</span></a><a class="ns-method" href="vector-distance.html"><code class="nm-sig">Vector.distance(a, b) -&gt; fixed</code><span class="nm-tip">The distance between two points.</span></a><a class="ns-method" href="vector-normalize.html"><code class="nm-sig">Vector.normalize(v) -&gt; Vector</code><span class="nm-tip">A unit vector in the same direction.</span></a><a class="ns-method" href="vector-lerp.html"><code class="nm-sig">Vector.lerp(a, b, t) -&gt; Vector</code><span class="nm-tip">Linear interpolation between two vectors.</span></a><a class="ns-method" href="vector-rotate.html"><code class="nm-sig">Vector.rotate(v, angle) -&gt; Vector</code><span class="nm-tip">Rotate a vector by an angle in radians.</span></a><a class="ns-method" href="vector-angle.html"><code class="nm-sig">Vector.angle(v) -&gt; fixed</code><span class="nm-tip">The angle of a vector in radians.</span></a><a class="ns-method" href="vector-from_angle.html"><code class="nm-sig">Vector.from_angle(a) -&gt; Vector</code><span class="nm-tip">A unit vector pointing at an angle.</span></a></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>