<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Gamedev Math on Godot 4 レシピ</title><link>https://kamera25.github.io/godot_recipes/4.x/math/index.html</link><description>Recent content in Gamedev Math on Godot 4 レシピ</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Tue, 09 Apr 2019 19:49:14 -0700</lastBuildDate><atom:link href="https://kamera25.github.io/godot_recipes/4.x/math/index.xml" rel="self" type="application/rss+xml"/><item><title>Interpolation</title><link>https://kamera25.github.io/godot_recipes/4.x/math/interpolation/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/math/interpolation/index.html</guid><description>&lt;p&gt;&lt;strong&gt;Linear Interpolation&lt;/strong&gt;, or its commonly-used abbreviation &lt;strong&gt;lerp&lt;/strong&gt;, is a term that comes up often in game development. If you&amp;rsquo;ve never come across it before it can seem mysterious and highly-technical, but as you&amp;rsquo;ll see in this tutorial, it&amp;rsquo;s actually a straightforward concept with a wide variety of applications in game programming.&lt;/p&gt;
&lt;h2 id="numeric-interpolation"&gt;Numeric Interpolation&lt;/h2&gt;
&lt;p&gt;The core formula for linear interpolation is this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-gdscript" data-lang="gdscript"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#81a1c1;font-weight:bold"&gt;func&lt;/span&gt; &lt;span style="color:#88c0d0"&gt;lerp&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;a&lt;span style="color:#eceff4"&gt;,&lt;/span&gt; b&lt;span style="color:#eceff4"&gt;,&lt;/span&gt; t&lt;span style="color:#eceff4"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;return&lt;/span&gt; &lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#b48ead"&gt;1&lt;/span&gt; &lt;span style="color:#81a1c1"&gt;-&lt;/span&gt; t&lt;span style="color:#eceff4"&gt;)&lt;/span&gt; &lt;span style="color:#81a1c1"&gt;*&lt;/span&gt; a &lt;span style="color:#81a1c1"&gt;+&lt;/span&gt; t &lt;span style="color:#81a1c1"&gt;*&lt;/span&gt; b
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In this formula, &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; represent the two values and &lt;code&gt;t&lt;/code&gt; is the amount of interpolation, typically expressed as a value between &lt;code&gt;0&lt;/code&gt; (which returns &lt;code&gt;a&lt;/code&gt;), and &lt;code&gt;1&lt;/code&gt; (which returns &lt;code&gt;b&lt;/code&gt;). The function finds a value the given amount between the two. For example:&lt;/p&gt;</description></item><item><title>Transforms</title><link>https://kamera25.github.io/godot_recipes/4.x/math/transforms/index.html</link><pubDate>Tue, 09 Apr 2019 19:49:14 -0700</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/math/transforms/index.html</guid><description>&lt;p&gt;Before reading this, make sure you have an understanding of vectors and how they&amp;rsquo;re used in game development. If you don&amp;rsquo;t, I recommend you read this introduction I wrote for the Godot documentation:
&lt;a href="https://docs.godotengine.org/en/latest/tutorials/math/vector_math.html" target="_blank"&gt;Vector Math&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="2d-transforms"&gt;2D Transforms&lt;/h2&gt;
&lt;p&gt;In 2D space, we use the familiar X-Y coordinate plane. Remember that in Godot, as in most computer graphics applications, the &lt;strong&gt;Y&lt;/strong&gt; axis points downward:&lt;/p&gt;
&lt;p&gt;
&lt;a href="#image-591890fbed12b243f774ebfd907ae8f2" class="lightbox-link"&gt;
&lt;img src="https://kamera25.github.io/godot_recipes/4.x/img/0_2d_coordinate_plane.png?width=250px" alt="alt" style="height: auto; width: 250px;" loading="lazy"&gt;
&lt;/a&gt;
&lt;a href="javascript:history.back();" class="lightbox" id="image-591890fbed12b243f774ebfd907ae8f2"&gt;
&lt;img src="https://kamera25.github.io/godot_recipes/4.x/img/0_2d_coordinate_plane.png?width=250px" alt="alt" class="lightbox-image" loading="lazy"&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To begin, let&amp;rsquo;s consider this spaceship floating in space:&lt;/p&gt;</description></item><item><title>Vectors: Using Dot and Cross Product</title><link>https://kamera25.github.io/godot_recipes/4.x/math/dot_cross_product/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/math/dot_cross_product/index.html</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You&amp;rsquo;d like to understand what is meant by &lt;em&gt;dot product&lt;/em&gt; and &lt;em&gt;cross product&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;In this recipe we&amp;rsquo;ll introduce the concept of vector &lt;em&gt;dot product&lt;/em&gt; and &lt;em&gt;cross product&lt;/em&gt; and how they might be used.&lt;/p&gt;
&lt;h3 id="dot-product"&gt;Dot product&lt;/h3&gt;
&lt;p&gt;Dot product is an operation on two vectors that returns a scalar. It is often visualized as the &lt;em&gt;projection&lt;/em&gt; of vector A onto vector B:&lt;/p&gt;
&lt;p&gt;
&lt;a href="#image-378e20b02e288c5017ef8ec3dd200ebc" class="lightbox-link"&gt;
&lt;img src="https://kamera25.github.io/godot_recipes/4.x/img/dot_cross_04.png" alt="alt" style="height: auto; width: auto;" loading="lazy"&gt;
&lt;/a&gt;
&lt;a href="javascript:history.back();" class="lightbox" id="image-378e20b02e288c5017ef8ec3dd200ebc"&gt;
&lt;img src="https://kamera25.github.io/godot_recipes/4.x/img/dot_cross_04.png" alt="alt" class="lightbox-image" loading="lazy"&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is the formula for calculating the dot product:&lt;/p&gt;</description></item></channel></rss>