New answers tagged

1

Find all triangles that intersect with the plane, split them into two polygons and triangulate the polygons. If you want a cap, enumerate all vertices generated from the slice and create a cap to fill the possibly concave planar hole. The devil is in the edge cases where you go exactly through vertices and edges, so make sure to robustly handle those.


0

Let's go through this: t = 0.0 dt = 0.0 currentTime = 0.0 accumulator = 0.0 Okay, som basic initialization, this is good. However, as Boreal mentioned, dt of 0 will cause problems. And since you are intending to fix your timestep, you should perhaps make dt a const and just set the value to whatever you want up here. Also, your currentTime initialization ...


0

Damping is physics term for an influence within or upon an oscillatory system that has the effect of reducing, restricting or preventing its oscillations. I suspect your source article might have a typo & have meant clamping, which generally refers to restricting a value to a given range. As for achieving the visual effect, you might be able to get ...


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(); ...


6

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 ...


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 ...


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. ...


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.


0

What you're referring to as spin is formally called angular momentum. Depending on the level of detail you want, it can get complicated fast; this Q/A on Simulating Torque and Angular Momentum might be a good starting point.


0

To expand on (one way you could do) the mathematics behind @Gummibeer's answer.. Keep in mind this physics calculation d = vt + 1/2at2 or distance = initialVelocity*time + 1/2 acceleration * time2 Say your turret is at [0,0] and the enemy is at [10,0] and.. Say your bullet starts at 0 velocity, and accelerates at 1 unit/sec/sec If we aim at ...


0

I'm struggling with this too. What I'm doing is keeping the velocity constant, and changing the direction of the object. If I make is so the angle (in degrees) is equal to the distance from the origin, times a constant, i get a nice perfect archimedean spiral. larger constants get less space between the lines. Only issue is if the speed is too high, then ...


4

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 ...


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 ...


0

For MLCG constants you want an odd number that's a multiple of five (assuming no explicit modulo). That'll be a weak PRNG. For Weyl like generators in integer you want an irrational scaled and rounded to odd...golden ratio and sqrt of two are good choices. That will give you a weak low discrepancy sequence. Neither of these tend to work well for hashing. ...


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. ...


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 ...


0

And easy way to handle large numbers is simply to have more than one INTEGER value then CARRY any overflow. If you have a 16-Bit INT value (0 to 65535) and you want to have more than that, use two 16-bit INT values in a row. Think of it like having a BYTE value (0 to 255) but only using it up to 99 digits of value. Once it hits 100, then roll it over to ...


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 ...


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 ...


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 ...


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 ...


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 ...


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 - ...



Top 50 recent answers are included