/docs/wiki: G1. Trigonometry starter

This commit is contained in:
veclavtalica 2025-03-12 01:36:42 +03:00
parent 8607aa48ec
commit e974194af0
3 changed files with 49 additions and 3 deletions

View File

@ -9,7 +9,7 @@
<a>Awesomeness</a>
<table style="padding-top:1em">
<tr><td>T1.</strong> <a href="#about-townengine">About Townengnine</a></td>
<td>G1.</strong> <a href="#making-2dot5d-shooters">Making 2.5D Shooters</a></td>
<td>G1.</strong> <a href="#trigonometry">Trigonometry</a></td>
</tr>
<tr><td>T2.</strong> <a href="#input-system">Input System</a></td>
</tr>
@ -32,7 +32,7 @@
<blockquote style="margin-top:0">
<p style="margin:0">T3.1 <a href="packaging.html#overview">Overview</a></p>
</blockquote>
<p style="margin-bottom:0"><a name="making-2dot5d-shooters"></a>G1. </strong><a href="making-2dot5d-shooters.html">Making 2.5D Shooters</strong></a></p>
<p style="margin-bottom:0"><a name="trigonometry"></a>G1. </strong><a href="trigonometry.html">Trigonometry</strong></a></p>
<blockquote style="margin-top:0">
</blockquote>
</body>

View File

@ -6,7 +6,7 @@
</head>
<body>
<h1 style="margin-bottom:0in">X1. {About}<span style="float:right">{twn}</span></h1>
<a href="index.html">Go back
<a href="index.html">Go back</a>
<p><a name="{Section}"></a><strong>X1.1 </strong><strong>{Section}</strong>
<blockquote>
<p>Text

View File

@ -0,0 +1,46 @@
<!doctype html>
<html>
<head>
<title>Townengine Wiki : Trigonometry</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1 style="margin-bottom:0in">G1. Trigonometry<span style="float:right">{twn}</span></h1>
<a href="index.html">Go back</a>
<blockquote>
<p>Truth is, most games are played in continuous space, where geometry matters.
Math classes turn out to be not so useless after all.
But even if you don't know your numbers well, you can compose functions by their meaning, and not number logic.
This page will try to help you with that, providing examples.
</blockquote>
<p><strong>the Hell are Vectors</strong>
<blockquote>
<p>There are distinct meanings they posses: <i>position in space</i>, <i>travel between points</i> and <i>direction</i>.
Often you need to juggle those representation around.
<p>For example, player and enemy positions by themselves don't tell you anything about their spatial relation.
For that you need to compute the <i>difference between them</i>, which is plain per component subtraction.
Resulted direction of travel depends on order of inputs, - it will point to position on the right side, the one you subtract with, but not from.
<p>It's important to understand that after subtraction the travel vector doesn't have relation with original positions,
it is effectively in a <i>subspace</i>, where (0,0,0) is at position you subtracted with to get it.
Operation is reversible by means of addition, resulting in position in space once again.
<p>I often forget what the direction is pointed at but here's a quick way to remind yourself: take two numbers, 10 and 0, and try subtracting them in different order.
Sign of result will tell you which part is pointed at, +10 -> direction is to the 10, -10 -> direction is to the 0. (Draw it in your head)
<p>Sometimes direction is more important than the travel, for which you need to drop the length of it.
This is called <i>normalization</i>, where result is called a <i>normal</i> (You probably heard those terms).
This is achieved by dividing every component by the length (magnitude) of vector itself.
Length is computed as <i>sqrt(x*x, y*y, z*z)</i>. This effectively creates a vector of length 1.
As every direction sized the same, when graphed they trace a circle.
</blockquote>
<p><strong>Center between two points</strong>
<blockquote>
<p><b>Method one. </b>Add two positions and divide them by two: (a + b) / 2. This is cheap, but harder to remember.
<p><b>Method two. </b>Find the travel between points, divide it by two and then translate the origin: (a + (a - b) / 2)
</blockquote>
</body>
</html>