Questions tagged [geometry]

A branch of mathematics concerned with questions of shape, size, relative position of figures, and the properties of space.

393 questions
1k views

Algorithm for “healing” multiple rectangles into a smaller number of rectangles?

Say I have a grid of rectangles of different shapes and colors and I want to reduce (reasonably close to optimal is fine, optimal is not necessary) the number of rectangles to represent the same ...
24 views

Lengthen Line (bidirectional) - crossing zero line

I'm trying to lengthen a line, by a certain amount. I want to apply the modification to both points on the line, expanding it in both directions. without moving it from it's current position (center ...
34 views

Calculating the inverse mesh of a 2D mesh inside a bounding box

If I have a mesh (drawn in red below) How can I calculate the inverse of the mesh (drawn in red below), given that the mesh is always constrained by the same four vertices of the encompassing ...
105 views

What shapes interlock solidly like cubes?

What basic geometric shapes, besides cubes, interlock "minecraft" style like cubes? A small edit to make question more suited to Game Dev: I am experimenting with game dynamics to create geometric ...
118 views

is there a way to check if a point is inside circle, other than distance between points?

Is there a way to check if a point is inside circle, other than distance between points? I am struggling with floating point precision problems. Is there some method to do the same test, but with more ...
3k views

How to draw an arc between two angles?

I'd like to draw an arc between two specific angles. For example, "draw an angle between 0 and 90 degrees" and it will draw only that part of the circle and ignore the rest.
227 views

Best way to test if some point on a line if in front of another point on the same line in 3D

I have a line in 3D defined by point P0 and direction vector D. For given input point P on a line defined as above, I want to test if P is in front of point P0. The code will be used in GLSL fragment ...
957 views

Calculate length of isometric line

In my isometric game the user can draw a line of arbitrary length, and I need to calculate the "unprojected length" of the same line. Users can only draw lines in 6 directions (4 isometric directions ...
84 views

How can I detect handedness of normal maps in a shader?

I've implemented normal maps into my game renderer using the formulas by Christian Schuler. It works OK with most normal maps but some not so much since in some the Y component (green) is reversed. ...
108 views

Point plotting with a line graph

Please see attached screenshot. Here's how it works. A is a slider that goes up and down, and the red line uses the centre point of the A slider to draw its start point. B is another slider, but ...
53 views

Check if a 3D mesh is a rectangular prism

I have a mesh post-processor in Unity that automatically a convex mesh collider to objects that need one (mostly all). Sometimes however there are objects that only need a box collider instead. ...
79 views

What is the formula for the collision of two “stretched spheres”?

In Smash Bros Melee, hitboxes aren't perfect spheres or boxes. They are, instead, a shape that looks like a continuous line of consecutive spheres: I.e., the geometry can represented as: ...
58 views

rough texturing on edges of mechanical parts

How do major studios fake the effect of "wear & tear" on the edges of guns and other things? I've always wondered this, but today it got to the point where I figured, why not just ask you guys. I"...
229 views

Applying texture inside of an Icosphere?

I have implemented a code to generate an Icosphere procedurally in Unity 5.3.4f, which works pretty well. However, what I need to do know it tweak the code to make the sphere to receive texture only ...
178 views

In Unity shaders, how is IN.worldRefl calculated?

I want to know how the world reflection vector in shaders is calculated so that I can manipulate it, but there is no documentation on what it does or how Unity calculates it. How is the reflection ...
164 views

HLSL topology mismatch question

I'm trying to write a fur shader with the shells & fins technique. Currently I receive this DirectX error D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: The declared input primitive type in ...
97 views

Draw a square given 2 corners

I am at the moment trying to come up with a simple method to extract some data points, given two corners. A*************** **************** ***************B I ...
537 views

Could triangles be used for swept-AABB checks between positions?

I'm trying to understand swept-AABB collision detection. When checking for collisions between two positions of an object, I commonly see one of 3 strategies used: Rays: trace rays from parts of the ...
124 views

Why do I have to do minus-equals for the x-coordinate but plus-equals for the y-coordinate?

I found a simple script in C# in Unity5 to make the camera follow the mouse: ...
218 views

LibGDX - Trying to make a radar-like display

i have an interesting question about geometry. I have two or more moving objects outside of my stage's viewport (blue and red circle in the image below), which i want to point at with two arrows on ...
1k views

Get water flow direction vector from water normal vector

Im stuck developing an important detail of my game water: Making it flow downwards! Considering a typical 3D world in wich water tends to go towards gravity ...
33 views

How to calculate the magnitude of the drag in Corona-sdk?

I'm making a game on Corona that launches a ball. The force is based on the magnitude of the drag: the larger is the drag -> the higher is the force. I'm having some trouble to do this, because I ...
258 views

How to find a point on a plane?

I'm using unreal engine 4. Currently I ray trace to a surface in game and I'm trying to find the location of the point relative to the surface1 instead of the world. I have the world position of the ...
145 views

How to convert Non-Axis Aligned Bounding Boxes to AABB

I'm trying to write a raytracer to render boxes (cubes) that are arbitrarily rotated, i.e. not necessarily axis aligned. While I'm reasonably comfortable ray-tracing an axis-aligned cube, I don't know ...
138 views

What technique should I use to implement the following type of “diggable” terrain?

I'm trying to replicate a certain game mechanic from the game Diggles. This game takes place in a vertical cross-section of the earth and allows the player to dig tunnels and caves into the ...
278 views

Normal to an edge of a polygon, from a point inside the polygon

Suppose that I have a closed boundary that is represented by n points. Using these n points I construct a polygon with ...
442 views

How do I calculate the tangent to a point on a circle?

I have a line that is from the center of a circle to a point on it's edge that is changing constantly (radius is drawn to a point orbiting a circle) I want to make a line tangential to the circle ...
81 views

Calculate total area of a composition of images

I'm trying to calculate the total area of a game object composed of several images. For each image, I know: Width, Height X, Y Rotation ScaleX, ScaleY OriginX, OriginY Where OriginX/Y are floats ...
126 views

I'm using Shader-toy to experiment and try to learn a bit the shader science. As exercise I wan to replicate some of the wikipedia math plots. I've started with a Super Formula. What I want to ...
466 views

Best way to find line segment intersection

I need to find the point of intersection between two line segments in 2D space. I receive them in terms of both coordinates of both lines. Because they are line segments I would also need to know if ...
160 views

Help with drawing a polygon with N sides [closed]

I am at university on my games development, and I have been given work to fill in an empty pixel plotter program using the methods they have supplied for it to teach us the algorithms used in 2 ...
490 views

How could we use trigonometry for moving around a 3D World?

Well I have a question about geometry and 3-Dimensional player movement in general. I'm using Java, OpenGL and LWJGL. This is basically what I got: currentFrontSpeed: Is a float that contains the ...
78 views

What is the best way to check for intersection of two bounding boxes, given a minimum and maximum Vector3 for each one

I have a BoundingBox object which holds two Vector3's (x, y, z), one for the minimum point and one for the maximum point. (-1.5 0 9 | 1.5 3 10) What is the best way to check for any intersection or ...
145 views

How can I fade in 3D foliage smoothly?

Take a look at this picture: This is a picture of me diving down from a high height. As you can see, the world is a simple world with grass, snow, trees, etc. The problem here is the 3D foliage. If ...
47 views

How to enforce touching within a ring shape?

I'd like to have the player moving the finger within the shaded ring: The game should be able to detect "out-of-boundary" events once the finger moves outside the ring. How can I accomplish this?
596 views

What is the Z plane?

I am learning the basics of geometry shaders and I came across references to the "Z plane." It's pretty easy to visualize the X and Y planes, but where does the Z plane reside in Cartesian space? ...
523 views

Vertex normals in the geometry shader using directx

I'm in directx 11 with the geometry shader. Is is possible to calculate vertex normals? Just one like segment per vertex? In the geometry shader? I did vertex normals per face, this is what I got, ...
213 views

2d grid vision(eye sensor) for a neural network bot?

I have a 2d grid and neural network bots living above it. What is a good way to give them vision of tiles in front of them? Below I describe my idea that I don't know how to efficiently(or ...
83 views

What is the fastest way of drawing simple, textured geomtries and keeping the depth test?

I'm looking for a fast way to draw simple 3D geometries - that will consist of up to 10 vertices. Each of them will have a texture (though varying between geometries). I also want to store the ...
2k views

Generate Geodesic Sphere from Hex and Pentagons

I have two polygonal meshes, a hexagon and a pentagon (They are tiles in a strategy game). I want to use them to construct a geodesic sphere (https://upload.wikimedia.org/wikipedia/commons/e/e7/G%C3%...
550 views

List cells in a 2D grid that belong in a sector / portion of a circle

Are there any algorithms to find out which cells in a 2D grid lie inside/is part of a slice of a circle - a pie slice shaped region? Essentially, as per image below, I need to list out all the green ...
519 views

Dual Contouring - Finding the feature point, normals off

I am following this tutorial to implement Dual Contouring http://www.sandboxie.com/misc/isosurf/isosurfaces.html My data source is a grid 16x16x16; I traverse this grid bottom to top, left to right, ...
104 views

Finding vector from a vertex to a plane

I am trying to implement Dual Contouring, following serveral sources, mainly http://www.sandboxie.com/misc/isosurf/isosurfaces.html but now I want to implement finding the feature point as explained ...
367 views

Creating force shields: the most efficient way of deforming/reshaping a simpler convex mesh so it envelopes a complex mesh?

So, the best way I can think of how to explain what I need is the following (images used here are just random images found trough google image search). What I am trying to create during run-time is ...
248 views

Finding new position after collision with multiple colliders

What is the most accurate way to find the correct position to where a moving character should be re-positioned as a collision-resolution, after it has collided with multiple colliders? The figure ...
224 views

How to find out the vertices of the polyhedron formed by the overlapping area of two rotated boxes?

What is the most efficient way for finding out the vertices of the polyhedron formed by the overlapping area of two rotated 3D boxes? If it is still confusing what I mean by "polyhedron formed by...",...
4k views

How do I efficiently check if a point is inside a rotated rectangle?

Part for the sake of optimization, part for learning purposes, I will dare to ask: How can I most efficiently check whether a 2D point P is inside a 2D rotated ...
951 views

Is there an efficient way to identify in which run-time generated room a character is, in a non-grid 3D environment? How?

Here is what I am trying to implement. I wrote a script that allows the player to place walls during run-time, in non grid-based 3D environment (walls can be diagonal with rotation increasing/...