22 lines
No EOL
4.4 KiB
HTML
22 lines
No EOL
4.4 KiB
HTML
<!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) -> 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() -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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> |