  AntiTwister

Member

24

185 Neutral

• Rank
Member

• Interests
|programmer|

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. This might be overkill for your needs, but if you want to also be able to tweak when you switch from accelerating to decelerating I put this together a while back: https://www.desmos.com/calculator/3zhzwbfrxd
2. That's crazy, was it an empirical result or did he prove it rigorously? About a year ago I was banging my head against a wall trying to derive a function that would remap uniform angles to a uniform sampling over the integral of the changing slice circumference, and it just turned into a nasty mess I couldn't simplify. Can't believe that the function I was looking for was cosine!
3. Alright, I did some investigation and I retract my earlier statement. I was aware that uniformly sampling polar angles would create bunching near the poles and I didn't expect uniformly sampling along a fixed axis to be any better, since it was not immediately obvious to me that slicing a sphere at uniform intervals along the z axis would divide the sphere surface into pieces of equal area. It looks like http://mathworld.wolfram.com/SpherePointPicking.html agrees that this is actually the case. I will edit the above post accordingly. Edit: looks like your edit beat me to the punch :)
4. Relatively new, yup... is it that obvious? :)
5. EDIT: I retract the following, it was based on incomplete knowledge extrapolated from uniformly sampling polar coordinates. ------ You should be aware that this distribution is not uniform and if you emit a lot of particles you are likely to see clustering, especially toward the poles. If the clustering is acceptable then this is probably the best solution, otherwise you may prefer to use a function which generates uniformly random points on the surface of a sphere and iterates until it finds a point that lands inside of your cone. Normalizing the output of a multivariate Gaussian distribution is a good way to get a uniform distribution on the surface of a sphere, see https://en.m.wikipedia.org/wiki/Multivariate_normal_distribution
6. You just need a change of basis. Find the two vectors that define adjacent sides of a diamond, then project your point onto each to find how far your point is in each of the tile space directions. This is functionally equivalent to taking the two diamond side vectors, plugging them as rows into a 2x2 matrix, taking the inverse of that matrix, and then multiplying your vector on the left by that matrix on the right.
7. For smooth interpolation of orientations you will want to store them in quaternions. Typically there are functions that will allow you to compute a quaternion from an axis/angle representation, and once you have it in quaternion form you can concatenate rotations by multiplying, and rotate the opposite direction by taking the inverse. You will want to store two quaternions. The first is the current orientation of the globe, and the second is the goal orientation of the globe. These are both rotations that would take you from the original, unrotated state of the globe to a world space orientation. The goal orientation will be computed by multiplying the rotations needed to move from an unrotated state until the target is aligned horizontally, followed by the rotation to align it vertically. Once you have these two orientations, you can interpolate between them using slerp (generally provided with any quaternion implementation). If it isn't available, you can compute the delta rotation as the inverse of where you started concatenated with your goal; i.e. the rotation that undoes your current orientation and then rotates to your goal orientation. Convert this to angle-axis, scale down the angle, convert back to quaternion and then multiply in to your current orientation to move partway to the goal.
8. If you want to do something similar for the vertical tilt, you can store a second angle that is applied as a rotation after the horizontal rotation is applied, about the axis which is a cross product between the player's view and world up. The angle delta would be handled similarly to the horizontal, but instead of atan2 the easiest way to compute it would be asin(v.y / v.Length())
9. I am assuming that the globe should only rotate about the y-axis, if that assumption is incorrect let me know. Given that assumption, you are only dealing with a horizontal angle of rotation. In the local space of the globe, you can use target_angle = atan2(p.z, p.x) for a point on the surface in the local (unrotated) space of the globe to figure out the angle that corresponds to that point. Similarly, you can take view_angle = atan2(-viewray.z, -viewray.x) with your view direction to get the angle that is facing toward you when the globe is unrotated. The absolute world orientation needed will be the delta that rotates target_angle to match your view_angle, i.e. goal_angle = view_angle - target_angle. You will then want to smoothly interpolate from whatever angle the globe is currently using toward this goal_angle.
10. The moment of inertia is generally used as a function to convert between torque and angular velocity. Because there is only one plane through which objects can rotate in 2D, the torque and the angular velocity will always be in the same plane, and thus the function which maps torque to angular velocity takes only one input and produces only one output. This function also happens to always be a linear mapping, which means the function can be represented as a matrix. A matrix which maps just a single input value to a single output value is a 1x1 matrix, and effectively becomes just a scalar. So yes, in 2D the moment of inertia, like the mass, is a value that scales an input. The mass tells you how difficult something is to translate and scales down linear forces, and the moment of inertia tells you how difficult something is to rotate and scales down angular torques. For a single point, the amount of work it takes to rotate it is proportional to its mass and the square of its distance from the axis of rotation. I = m*r^2 For any other shape, you can break it down into an integral over the set of points that make up the shape. Integrals really just sum up the contributions of all of the points, distributing an equal infinitesimal part of the mass of the whole to each one. For instance, given a rectangle with a mass m, height h, and width w, you can break it up into an infinite number of micro-areas that are a width of dx, a height of dy, and have a mass of m * (dx*dy) / (w*h), i.e. the percentage of mass that little piece has relative to the area of the whole. Each piece would then contribute that area times the distance of that piece squared from the axis of rotation (usually the center of mass of the shape). I won't go into all of the details here, but there are plenty of resources online for how to compute a double integral, which is what you need for summing up contributions over a 2D area. I recommend starting here: https://betterexplained.com/articles/a-calculus-analogy-integrals-as-multiplication/ Wikipedia has a list of moments of inertia for some common shapes here: https://en.wikipedia.org/wiki/List_of_moments_of_inertia
11. I decided to finish solving this; I don't have a proof per se since I did most of my equation simplification in notepad and lost the intermediate work while I was moving terms around, but I do have something visual that might be better. https://www.desmos.com/calculator/hpcca2u3cc (q0, p0) is the first known point, (q1, p1) is the second known point, and p2 is the y coordinate of the third known point at the bottom of the parabola. You can slide these values around to see how it affects the shape of the parabolas and where the solution becomes degenerate. I found that this problem gets a lot easier if you make everything relative to the first point before solving it. Notice that the parabola you probably want (which has the point at the minimum height in between the other two points) switches when q0 is made greater than q1.
12. You may have intended to specify that equation in your original post, but if you check again I think you will find it doesn't appear there. I assumed it was what you intended and specified it in the beginning of my reply. Doesn't really matter, it was obvious what you meant :)
13. The distinction is that a rotated parabola is still a parabola even if it doesn't pass the vertical line test. The set of parabolas described by quadratic functions are the subset of all parabolas in which the axis of symmetry is vertical.
14. You are trying to find a, b, and c in the equation y=ax^2+bx+c. You can plug your two known points into this equation to get two equations with three unknowns. The third point you need to find is a location on the derivative: 0 = 2ax + b. Solve for x in terms of a and b, and that gives you your third point to plug into the equation: (-b/(2a), min height). Now you have 3 equations and 3 unknowns, which you should be able to substitute and solve.
15. Printf formatting will definitely cause you to flip a bit or two. You might consider reinterpret_casting the memory to print it as a uint32 in hex, assuming you can't just dump the binary value directly. The TOC calculation will never be perfect with floats, and you need an epsilon to handle the fact that you might not be absolutely perfectly coplanar at that point in time (this gets worse when you have a more involved toc calculation, like finding the roots of a cubic). Resolution also definitely needs an epsilon, because otherwise your velocity or even just final position can again be off enough from coplanar that you end up on the wrong side. Using cubics with a collision epsilon we discovered that you need to test both the computed continuous TOCs and at a TOC of 1.0, because the cubic on the next timestep could be different enough that it ends up reporting a collision at 0.0 when the previous timestep didn't find one. A collision at 1.0 can still be solved without issue by moving the ending position to be epsilon above the collision plane in the normal direction (there's just no time left in the step to keep sliding). However a collision at 0.0 can never be solved because during the step your starting location never changes - just where you end up. If you start out colliding, no resolution of your endpoint will change that fact. If you are extremely turned off by introducing epsilons, CGAL (http://www.cgal.org/exact.html) takes the philosophy that geometry calculations should be exact, and has algorithms for continuing to zoom in on a problem until it can provide a solution with 100% accuracy. Obviously this will never be as cheap as just computing with floats, but if you are interested in the topic it might be worth researching.