Hot answers tagged

32

If you just want to store massive numbers without complete accuracy, for example if you're going to show 12,567,000,000,000 as 12.567T (trillion), you could just use standard float/decimal values and show the first x significant figures, with a suitable suffix like this. When you're in the octillions, do you really need to care about each individual integer ...


17

In practice, no additional overhead will be incurred. In C++, small functions are usually inlined by the compiler as an optimization, so the resulting assembly will have all the operations at the callsite— the functions won't call each other, since the functions won't exist in the final code, only the mathematical operations. Depending on the compiler, you ...


16

You could use something like BigInteger, which is only available in .net 4.0 if I am not mistaken (not supported by all unity build platforms). There are some libraries that attempt to bring this functionality without the requirement of .net4.0 however. For example here. Alternatively, you can use smaller numbers to represent a larger one, by keeping ...


8

You'd likely need to write your own class for use in Unity, but it wouldn't be particularly hard. Internally, it could be a list of integers (such as a List<int>), with each element in the list corresponding to a group of 9 digits. Each integer would have a range of 0 to 999 999 999. An integer can support a little over 2 billion, and double that if ...


5

For handling big numbers, I'd look at what I think is a good example like Tower of Hero. Top left corner: Without getting into gameplay, the way it handles numbers is relatively simple: You see two buckets of numbers. As you get higher in the tower, and make more "gold", the two buckets simply represent larger numbers. 120 120M320K - 120 Million ...


5

I don't know what their project does but you can apply a reshaping function to height. Here's an example that takes h from 0.0 to 1.0 and returns a new height from 0.0 to 1.0: function R(h) { var W = 0.4; // width of terracing bands var k = Math.floor(h / W); var f = (h - k*W) / W; var s = Math.min(2 * f, 1.0); return (k+s) * W; } It's ...


4

You don't seem to need the angle, only the delta vector between the two positions. vA = vector representing position of A vB = vector representing position of B vD = vA - vB // distance and direction to travel vD / len(vD) = vDu // direction of travel And you multiply vDu with your speed per frame, this will give you the distance per frame.


4

You don´t need the angle. Just use: x(v)= x(a)-x(b) y(v)= y(a)-y(b) Your new vector (x,y) (v) will have the ammount of movement in X and in Y axis needed to go from one point to another. You can then calculate the ammount of distance per frame based on this vector.


4

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 multiplication of numbers WXYZ and PQRS (all these letters representing arbitrary digits in any base) and see how the digits get added together in ...


3

Presumably you have the center point of the ring (c), and the radius of the inner and outer segments of the valid portion of the ring (ri and ro, respectively) Then, given any touch point p, you simply need to perform two point-in-circle tests. The touch is valid (within the ring) if it is both outside the inner circle and inside the outer circle. A point p ...


3

In the case of a puzzle like this you can animate the rotation then reset the model back to its original position but with the cube's stickers rotated. Look at it like cheating with a real puzzle by moving the stickers. You'll have to make it possible to change the stickers' colors. This can be done with material colors or a dynamic texture. And this way ...


2

The idea is practically the same for 1D, 2D or 3D or any other dimension. First let's talk about a 1D scenario: We have two segments along x axis, and we know their start and their ends. let them be s1,e1,s2,e2. So what's the requirement for these two lines to overlap? well, we can say the first line should start before the second one ends, and vise versa. ...


1

It's a bit vague what you want to do and what you have. But this should help: Vector3 pos = new Vector3(); Matrix4 nodeTransform = new Matrix4(); nodeTransform.setToTranslation(2, 4, 0).rotate(Vector3.Z, 180f); nodeTransform.getTranslation(pos); Gdx.app.log("Node pos", pos.toString()); Matrix4 modelTransform = new Matrix4(); ...


1

Well, as you mentioned only mathematics tag so I'm assuming that you have to do everything manually, without built-in vectors functionality. So, I'm writing here on of the may methods to do so. First find the Slope between two points at which bullet A and B do exist, by which we can calculate angle through which I'll determine the direction. ...


1

The best way to solve this is not with trigonometry, but with vector math! I'm going to write some quick pseudocode of what you need to check for difference in angles, if you want the juicy details of the whys and hows scroll further down. Summary: float l1x = entity.getPosition().x - player.getPosition().x; float l1y = entity.getPosition().y - ...


1

It sounds like you want to implement your own physics instead of using what's built in. Fortunately, you don't have do any kind of parabolic calculation when jumping (unless you want to project the path of the character or something like that). Instead, you let physics run its course which will naturally create parabolic shapes. Here is some example code for ...


1

They are describing how to get the nearest point on the moving circle trayectory to the "checking" circle center, without using vector math. Or better , using it but without telling that. var t = dx * distToBubble.x + dy * distToBubble.y; is simply the dot product of the moving vector (velocity vector) and the direction vector from moving circle. Hope ...



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