Search Results
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 |
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 …
1
vote
Accepted
How do I find the largest circle possible in a square of pixels using Unity?
On a 40×40 square of pixels, you can draw a circle with approximately 40×sqrt(8) pixels.
If you are looking for a circle drawing algorithm to let you pick the pixels to put in your array, an easy way …
6
votes
What is a simple algorithm for calculating evenly distributed points on an ellipse?
Reasonable approximation
As already stated in other answers, there is no exact way to do this. However, it is possible to efficiently approximate a solution.
My formula will only handle the upper ri …
1
vote
How to draw a line of a given length towards a given object?
You do not need the angle itself, just the direction, which is given by vector End - Start. For convenience it's good to normalise that vector, ie. divide it by its length. You will then extrapolate o …
1
vote
Accepted
Finding the angle of a line given 2 other lines
All you need is atan2:
angle = atan2(frontwheel.y - rearwheel.y, frontwheel.x - rearwheel.x);
9
votes
Accepted
Understanding log/exp formula for RPG experience
When used together with exp, the log function is commonly understood as the natural logarithm. You are actually using base 10 logarithm (which would be log10 in C++).
Fortunately you can get the same …
6
votes
Accepted
How to draw equal length line stripes on a parabola?
The derivative of the ball position is:
dx/dt = vx
dy/dt = vy + gravity * t
So the derivative of the parabola arc length s is, using Pythagora’s theorem:
ds/dt = sqrt(vx² + (vy + gravity * t)²)
…
4
votes
Accepted
Adding tolerance to a point in polygon test
Since the algorithm already parses all edges of the polygon to see how many times a ray cast from test crosses them, I think it's reasonable to add a check to see whether test lies on the edge exactly …
38
votes
Accepted
Formula for three competing heroes, each has one they can beat and one they're beaten by
Your game is a nontransitive game. You can implement it with 3 stats R, P and S, using the rock-paper-scissors logic. Call these stats whatever you want, but I'll stick with the RPS logic.
Now suppos …
1
vote
Compute cone angle (cos) given side and hypotenuse vectors at time 0 and world matrix at time 1
Despite its name, Vector3.Transform() does not transform a vector but a point. The unwanted side effect is that the translation part gets added to your vector. If you want to actually transform a vect …
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 …
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) …
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 …
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: …
5
votes
Accepted
Tangent to a circle through a point
Let b be the angle between vectors p1p2 and p1p3. Its value can be computed as:
b = pi - atan2(p1p3.y, p1p3.x)
The angle between p1p4 and p1p3 is b-a. Since p1p3p4 is a right-angled triangle, we kn …