Tag Info

Accepted

I'm rotating an object on two axes, so why does it keep twisting around the third axis?

No this isn't an engine bug or an artifact of a particular rotation representation (those can happen too, but this effect applies to every system that represents rotations, quaternions included). You'...
• 135k
Accepted

What is a "normal" in game development

Direct Answer I see that other answer going into technical details, but I don't know if that hits the spot for answering "What are even normals" - so here's a plain English answer for ...
• 1,476

If a 3D vector represents a point, how can it have a length?

Does that mean that the magnitude is simply it is distance from the origin point (0, 0, 0)? That's exactly that. Among other things, a vector can represent a point (a position), a direction and/or a ...
• 16.3k
Accepted

How to compute the area of an irregular shape?

You can use Gauss' shoelace formula: You need to take the x coordinate of every point, multiply them by the next point's y coordinate, then subtract the current point's y coordinate multiplied by the ...
• 14.9k

What is a "normal" in game development

In the context of geometry, a normal is a vector that is oriented perpendicular to a given object. It is commonly used for lighting calculations, but it can also be used to for calculating visibility, ...
• 12.4k
Accepted

How do game engines avoid recalculating normals upon mesh rotation?

They don't. When you rotate a mesh, the normals in memory are not changed in any way. All that changes is the object's transformation matrix is updated. The raw mesh vertex and normal data remains ...
• 135k
Accepted

How can I get the normal vector for a plane from a set of vertices?

You could easily find the normal by calculating two vectors, V1 = P2-P1, and V2 = P3-P1, and then find the cross product N = V1 x V2. Then you normalize N. Depending on the ordering of the vertices (...
• 507
Accepted

If a 3D vector represents a point, how can it have a length?

Does that mean that the magnitude is simply it is distance from the origin point (0, 0, 0)? The tl;dr answer may be: Yes, you can imagine it like that. But I'm not sure whether this might not lead ...
• 673
Accepted

Algorithm for "healing" multiple rectangles into a smaller number of rectangles?

First, we can convert your source rectangles to cells in your underlying grid, to make the input more uniform. (Effectively rasterizing the problem) This will let us find optimizations that might not ...
• 135k

How does a 4x4 matrix represent an object in space and matrix lore?

How is Matrix Multiplication a Transformation? A matrix is just a big grid of numbers with rules that define how we can multiply it with other grids or lists of numbers. In games, we usually want to ...
• 135k

Procedurally generating a building of specific area

A simple way to build a procedural generator is: Randomly build things Run a function that checks whether the output is good If the output is not good, go to step 1 Even if it takes thousands of ...
• 14.8k

How do game engines avoid recalculating normals upon mesh rotation?

DMGregory's answer explains how this is actually handled, but I'd like to point out a couple of misconceptions: Assume that a face of a mesh is defined by vertices ...
• 5,508

Why are spherical worlds so rare?

Because spherical maps, compared to rectangular ones, create a lot of additional complexities regarding the technical implementation and the UI design while usually offering very little gameplay ...
• 120k
Accepted

Efficient minimum distance between two axis aligned squares?

By far the slowest part of this algorithm would be the square root. Try to avoid it if you can, and deal with the squared distance directly. For example, if you're comparing distances, the results ...
• 14.8k
Accepted

How to calculate the surface area of a mesh

Looking at the formula you're using, it looks like it's designed to calculate the area of a planar polygon, where the vertices are all in clockwise / counterclockwise order about the perimeter. That'...
• 135k

If a 3D vector represents a point, how can it have a length?

Does that mean that the magnitude is simply it is distance from the origin point (0, 0, 0)? You can see it that way, but only seeing it that way may lead to a wrong understanding. First of all, a ...
• 803
Accepted

Find ID from Spiral x, y positions. Hard programming formula

Let's add some colour coding to see if we can reveal some structure in the problem: Here I've colour-coded the spiral into concentric rings of alternating colours. You'll notice the tile just before ...
• 135k

How can I project a 3D point onto a 3D line?

Here's a fast and easy way to do it in python: ...
• 171

Procedurally generating a building of specific area

Given a restriction of "all areas are at are at least 3-4 blocks wide" the first idea that leaps to my mind is something like the following: pick one of 3x3, 3x4, 4x3 or 4x4 place a block of that ...
• 714
Accepted

Procedurally generating a building of specific area

You could use pre-generated polyominoes as meta shapes to build an assortment of buildings. Let's say your minimum acceptable distance is 3 blocks. Then the smallest acceptable building unit we'll ...
• 12.4k
Accepted

Most efficient way to calculate angle between two line-segments that do not necessarily touch each other

Let s1 and s2 the segments, so you can calculate the angle of each using ...
Accepted

How to draw an arc between two angles?

You can define an arc with a radius and start and end angle. Then you simply need to create a series of points to define the arc. ...
• 73.3k
Accepted

Determine the z coordinate of a deformed plane based on uv (xy) coordinates

Your image can be interpreted a couple different ways so I will make a few assumptions up front: The "geometry" you are emulating is meant to look as if it has already been "projected" (if it was ...
• 1,644
Accepted

How does one calculate the surface normal, in 2D collisions?

I think the following may help. You have the sphere center, box center and hopefully the details of the rectangle. Since the rectangle may be rotated we need the rectangle extents, and the ...
• 428

If a 3D vector represents a point, how can it have a length?

A vector can represent a line between two points in 3d space (direction and distance) or a location in 3d space (length is the distance from origin). If you have point A, and point B, then B-A = AB = ...
• 2,649
Accepted

How can I convert my list of vertices and indices to a list of triangles?

Typically, your list of indices looks like this: ...
• 135k
Accepted

How to determine polygon based on point lists?

A possible solution is to cull points that you are certain that are not part of the polygon. Start with a definition of the polylines: ...
• 4,067
Accepted

Point plotting with a line graph

You can solve this with some basic trigonometry. I wrote the code in Unity, but the general idea should be the same. Consider the following image: We already have P1 and P2. Here is some code to ...
• 8,424
We can solve this by completing the square: \begin{align} x^2 + y^2 + ax + by + 1 &= 0\\ \left(x^2 + ax \right) + \left(y^2 + by \right) + 1 &= 0\\ \left(x^2 + ax + \frac {a^2} 4\right) + \...