Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 5864

Mathematics questions deal with the arithmetic, geometry, calculus, formulae and other calculations used in the development of a game.

1 vote
Accepted

Get all points of a parabola

In general, there is no parabola that goes through three given points. However, if you loosen the problem constraints and only define the Y coordinate of the parabola’s top and allow its X coordinate …
sam hocevar's user avatar
  • 23.9k
3 votes

Integration error in high velocity

Say the object is 10 meters above ground. Assume that our dt (delta t) is 1 second. The object goes to the height of 9 meters at the end of the first iteration Here lies your problem. It is true …
doppelgreener's user avatar
20 votes
Accepted

Sorting array of points in clockwise order

Your question is not precise enough. An array of points is only « clockwise » or « anti-clockwise » relative to a reference point. Otherwise, any array of three points can always be either CW or CCW. …
Glorfindel's user avatar
2 votes
Accepted

Math to set tangential force?

You need a unit vector tangent to the planet surface: v = normalize((pY - oY, oX - pX)) Then just multiply v by your force amount.
sam hocevar's user avatar
  • 23.9k
1 vote

Find your value between four values in a grid based on distance, Unity

You do not need to do anything special: Perlin noise is a gradient noise and is designed to give you an interpolated value at any point, not just at the square corners. Just use your Perlin noise gene …
sam hocevar's user avatar
  • 23.9k
1 vote
Accepted

How does this point2LineDist() method works?

The direction vector of the red line is (CosTable[a], SinTable[a]). It is a unit vector. Now consider the green line on your drawing. The vector along this line pointing towards (x, y) is orthogonal …
sam hocevar's user avatar
  • 23.9k
2 votes
Accepted

Why does Mathf.Log(x) return infinity in this case?

Here is a more numerically stable (for large values) way of getting Log(Fn) where Fn is the nth Fibonacci number. Let φ = (1 + sqrt(5)) / 2 and ψ = (1 - sqrt(5)) / 2. Then the nth Fibonacci number is: …
sam hocevar's user avatar
  • 23.9k
0 votes

calculating the weights for direction vectors to a target

The distance between the centre of the circle (x1,y1) and the target (x2,y2) is: D = sqrt((x1-x2)² + (y1-y2)²) So the distance between the target and any point on the circle varies between D - r an …
sam hocevar's user avatar
  • 23.9k
0 votes

Velocity Relative To A Vector

The “velocity in a space” can be broken down in two vectors, one that is the same direction as a, and one that is perpendicular to a. The first vector has direction u and size su, computed as follows …
sam hocevar's user avatar
  • 23.9k
6 votes
Accepted

understanding spatial hash function behaviour and Knuth for int64

First of all, for uniformly distributed data, Knuth’s function i * 2654435761 >> 16 is definitely better than i * 2654435761 >> 8 because it shuffles more bits. An explanation follows. Consider the m …
sam hocevar's user avatar
  • 23.9k
3 votes

How to calculate normal vector of a Bézier curve?

If vector (x,y) is a tangent vector of your curve, then the normal vector is simply (y,-x). So you just need to find a tangent vector, and it all depends on how exactly you define the curve. If your …
sam hocevar's user avatar
  • 23.9k
3 votes

Usage of math.Atan2 in a 3D coordinate system with Unity

Beware of the argument order here. Here is what atan2 will give you: atan2(x,z) is the angle between the (x,0,z) vector and the +Z axis in the Z-X plane. atan2(z,x) is the angle between the (x,0,z) …
sam hocevar's user avatar
  • 23.9k
2 votes

Quaternion Slerp and Lerp implementation (with overshoot)

Here’s a little example. Suppose you slerp q0 and q1 with a value of t = 0.2 and a value of t = 0.4. This gives you a quaternion s(0.2) and a quaternion s(0.4). Quaternion multiplication also gives us …
sam hocevar's user avatar
  • 23.9k
1 vote
Accepted

Affine transformation: rotate a plane parallel to another plane

I need a way of translating a set of points P I suppose you mean rotating here? Let Z = (0,0,1). If cross(N,Z) has length 0, it means that all your points already lie in the desired plane. Other …
sam hocevar's user avatar
  • 23.9k
15 votes
Accepted

How do I lerp between values that loop (such as hue or rotation)?

It’s not always the best method, and it can be more computationally expensive (though this ultimately depends on how you store your data), but I will make the argument that lerping 2D values works rea …
Anko's user avatar
  • 13.4k

15 30 50 per page