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

22 lines
No EOL
4.4 KiB
HTML
Raw 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>IVec2 — Ludic</title>
<meta name="description" content="Integer 2D vector math for tile and grid coordinates, cell offsets, and integer sizes.">
<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">IVec2</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">IVec2</h1></div>
<p class="ns-blurb">Integer 2D vector math for tile and grid coordinates, cell offsets, and integer sizes. An <code>IVec2</code> is a pair of whole-number <code>int</code> components (x, y) packed into one value, so it is copied by value and never allocates. Every operation is exact integer arithmetic — no rounding, and bit-identical on every platform. Use it wherever a fractional part would be meaningless; reach for <code>Vector</code> when you need sub-pixel precision. Arguments are positional.</p>
<div class="ns-methods"><a class="ns-method" href="ivec2-make.html"><code class="nm-sig">IVec2.make(x, y) -&gt; IVec2</code><span class="nm-tip">Build an integer vector from x and y components.</span></a><a class="ns-method" href="ivec2-zero.html"><code class="nm-sig">IVec2.zero() -&gt; IVec2</code><span class="nm-tip">The origin cell, (0, 0).</span></a><a class="ns-method" href="ivec2-x.html"><code class="nm-sig">IVec2.x(v) -&gt; int</code><span class="nm-tip">The x component of an integer vector.</span></a><a class="ns-method" href="ivec2-y.html"><code class="nm-sig">IVec2.y(v) -&gt; int</code><span class="nm-tip">The y component of an integer vector.</span></a><a class="ns-method" href="ivec2-add.html"><code class="nm-sig">IVec2.add(a, b) -&gt; IVec2</code><span class="nm-tip">Component-wise sum of two integer vectors.</span></a><a class="ns-method" href="ivec2-sub.html"><code class="nm-sig">IVec2.sub(a, b) -&gt; IVec2</code><span class="nm-tip">Component-wise difference of two integer vectors.</span></a><a class="ns-method" href="ivec2-scale.html"><code class="nm-sig">IVec2.scale(v, s) -&gt; IVec2</code><span class="nm-tip">Multiply both components by an integer.</span></a><a class="ns-method" href="ivec2-dot.html"><code class="nm-sig">IVec2.dot(a, b) -&gt; int</code><span class="nm-tip">The dot product ax*bx + ay*by.</span></a><a class="ns-method" href="ivec2-equal.html"><code class="nm-sig">IVec2.equal(a, b) -&gt; bool</code><span class="nm-tip">True when both components match.</span></a><a class="ns-method" href="ivec2-manhattan.html"><code class="nm-sig">IVec2.manhattan(a, b) -&gt; int</code><span class="nm-tip">Grid distance |dx| + |dy|.</span></a><a class="ns-method" href="ivec2-to_vector.html"><code class="nm-sig">IVec2.to_vector(v) -&gt; Vector</code><span class="nm-tip">Widen to a fixed-point Vector.</span></a><a class="ns-method" href="ivec2-distance2.html"><code class="nm-sig">IVec2.distance2(a, b) -&gt; int</code><span class="nm-tip">The squared distance between two points.</span></a><a class="ns-method" href="ivec2-within.html"><code class="nm-sig">IVec2.within(a, b, radius) -&gt; bool</code><span class="nm-tip">Are two points within a radius of each other?</span></a><a class="ns-method" href="ivec2-heading.html"><code class="nm-sig">IVec2.heading(from, to) -&gt; int</code><span class="nm-tip">The direction from one point to another, in degrees.</span></a><a class="ns-method" href="ivec2-along.html"><code class="nm-sig">IVec2.along(origin, degrees, distance) -&gt; IVec2</code><span class="nm-tip">The point a distance along a heading.</span></a><a class="ns-method" href="ivec2-step.html"><code class="nm-sig">IVec2.step(degrees) -&gt; IVec2</code><span class="nm-tip">A -1/0/1 unit step along a heading.</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>