# Tag Info

8

I still think you need to understand basic trigonometry. But here is a simple introduction of how to use sin and cos to simulate a wave. The basic wave formula is: f(t) = A * sin( 2 * pi * f * t + phase ) Where: f is the frequency, which controls the number of times the waves repeats per unit time, f = 1/P where P is the number of periods. ...

6

I added a simpler curve to Nathan's answer, The curve is 1 - ( b - x ) / (c*x + b) It doesn't use log, and you can alter the steepness of the curve using the c parameter. When c=0, the curve becomes linear.

3

A common approach is to raise the values coming from the joystick to a power, for instance squaring them, which improves the sensitivity for small deflections but still allows you to access the whole range of movement with large deflections. Usually a joystick value comes to you in the [-1, 1] range. You'll want to preserve the sign when raising it to a ...

3

See this tutorial on circle-circle collisions: http://gamedev.tutsplus.com/tutorials/implementation/when-worlds-collide-simulating-circle-circle-collisions/ You seem to have most of the code implemented - go down to Step 4 (I think that's it anyway). It shows you how to calculate the new velocities. You might have to change how you calculate your updates, ...

3

If I'm not mistaken Math.tan(x) does not take angles as degrees, but rather radians. If you want to supply angles as degrees, try the following code sample: function getTanDeg(deg) { var rad = deg * Math.PI/180; return Math.tan(rad); } Source - Mozilla Developer Network

3

Sure, you can use a logarithmic function for this, for example: scale = log(score / 160.0 + 1.0) / log(maxScore / 160.0 + 1.0) Here, the value 160 is a constant that controls how steep or shallow the curve is. I also added 1.0 to make the curve start from zero (otherwise, the log function goes to negative infinity at zero). I used the Desmos online ...

2

You are comparing the world-space forward vector to the target (view-space) forward vector to calculate the rotation necessary to transform the camera into view-space right ? In that case, I think you should try to change the second line to float dot = glm::dot(glm::vec3(0.0f, 0.0f, -1.0f), forwardVector); since -if I'm not mistaken- in OpenGL, the camera ...

2

I would say... start with the fixed rectangle. Extend either the vertical or horizontal sides to the edges of the area; this gives you 5 rectangles (including the fixed one). Randomly choose any of the N non-fixed rectangles, cut it in half vertically or horizontally, giving you N+1 rectangles. Repeat until you have the number of rectangles you want.

1

Root finding comes to play when you want to calculate dynamic collision detection, in other words when your objects are moving, and your static collision detection method can't predict that your object at t+ delta t will at a different position, this is also called quantum tunneling. This happens due to the discrete nature of computers, that updates the ...

1

I would suggest a sweep approach. Starting from the origin, choose one axis (for example y, which I will consider as the columns axis) and generate random sizes for the rects until you reach the end of the axis. This will setup column[0]. For each rect[i] in column[j], you should save rect[i].finalX as the final x coordinate of this rect. To generate the ...

1

I suspect that positioning rectangles completely randomly could let to a lot of failed solutions, and no clear idea why a solution failed. My suggestion would be to start at the fixed rectangle and randomly generate adjacent rectangles. In a similar manner to a search such as A*, you would end up with a closed list and an open list, e.g. closed contains ...

1

Another possible algorithm. This is easily expandable as well and does not have to use % of 100: //assuming rand() returns integers #define numberOfPlatformTypes 3 int platform[numberOfPlatformTypes]; platform[0] = 10; platform[1] = 30; platform[2] = 70; int total = 0; for(int i = 0; i < numberOfPlatformTypes; ++i) total += platform[i]; int r = ...

1

Usually, a joystick axis goes from 0 to 1, with 0 being no movement and 1 being full movement. So if you are holding the left thumbstick halfway to the right, it would be 0.5f, and if you are holding it three quarters of the way to the left it would be -0.75f. What I suggest is only registering movement if the value is bigger than some threshold. For ...

1

So your max score is 15000, and you want to do everything on the log scale (I'm assuming base 10, but it doesn't matter as long as you're consistent. Some languages use e as a basis, some use 10). First you need to find the max score on your log scale that corresponds to 15000 (your chosen max). Then you'd just log transform your score and compute the ...

1

Usually, you define two routes for a camera flight. The first defines the position of the camera and the second defines the point the camera looks at. Both curves may be smoothed using Beziers or B-Splines. I don't quite understand the part of your question about the quaternion. Quaternions are representations of rotation, like angles but unambiguous. You ...

1

You might use Plane's Normal (in math), get your view's normal, get spheres or other objects position and every objects, plane's normal by their rotation, scale for size of collision tests, get distances and make a simple Ray collisions, so you can use that Boolean ray for your game, if your framework has Physic engine then certainly that engine has ray ...

1

I wanted to comment on the answer given by @Nathan Reed (which is pretty good, btw - I do not wish to make his answer less relevant by answering again), but I do not have enough reputation yet. Anyway, I just wanted to point out that you can try to use this Vector2D class from Kevin Lindsey: http://www.kevlindev.com/gui/math/vector2d/index.htm Include that ...

1

You can do this using vector math. There's a standard formula for reflecting an incoming vector (v₁) off a normal, which you can see derived on this page. The formula is v₂ = v₁ - 2 (v₁ · n) n Since it's a circle, the normal is just the normalized vector from the collision point toward the center of the circle. This is a good formula to put in a ...

Only top voted, non community-wiki answers of a minimum length are eligible