Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 10 May 2006
Offline Last Active Sep 07 2013 03:50 PM

#4864606 Rigid body rotation and movement

Posted by on 22 September 2011 - 05:12 AM

Actually, the linear accelleration is just the sum of all linear forces divided by mass :) so in your example, it's just 1.5F/M downwards, it doesn't matter where these forces are applied the linear acceleration is still the same.

#4850421 Predicting the 2D path of a rotating rocket?

Posted by on 17 August 2011 - 12:29 PM

your acceleration is:

a(t) = a * [ cos(r0+wt) ; sin(r0+wt) ]

for initial angle r0, constant rate of rotation w and time t with magnitude of accleration a

then; your velocity is:

v(t) = integral(0->t) a(t) = v0 + a * [ (sin(r0+wt)-sin(r0))/w ; (cos(r0)-cos(r0+wt))/w ]

for initial velocity v0

and your position is:

x(t) = integral(0->t) v(t) = x0 + a * [ -(wt.sin(r0) + cos(r0+wt) - cos(r0))/w^2 ; (wt.cos(r0) - sin(r0+wt) + sin(r0))/w^2 ] + t*v0

for initial position x0

since the acceleration only lasts for 5 seconds; all of these become piece-wise maps; defined as above for t = 0 -> 5, and then after t = 5, you'd go back to normal equations of motion with:

a(t>5) = [0 ; 0]
v(t>5) = v(5)
x(t>5) = x(5) + (t-5)*v(5)

and in all cases your rotation follows:

r(t) = r0 + tw

#4850080 Converting coordinate systems

Posted by on 16 August 2011 - 05:24 PM

Your coordinate system is defined by the 3 axis vectors and the centre vector which together produce a 4x4 matrix:


So you have two coordinate systems A and B.

To go from coordinate system B to coordinate system A, you would premultiply the point/vector with AB-1

Of course you can probably simplify the maths greatly, if your axis vectors form an orthonormal set of vectors, in which case the upper 3x3 part of the coordinate system basis is an orthogonal matrix, and so it's inverse is simply it's transpose and so to premultiply with B's inverse, you would just subtract the centre vector, then premultiply with the transposed upper 3x3 part.

#4846680 To goto or not to goto?

Posted by on 09 August 2011 - 08:03 AM

While I'm at it, I might as well add one more. Since we're using the goto for a quick and dirty exit, why not a return statement then?

// whatever came after...
// ...

void loopFuncWithNiceName()

  for (int i=0; i<n; ++i) {
    switch (some_array[i]) {
      case 0:
      case 1:
        if (some_condition())
          return;// DONE!!!

Because using a return doesn't give you the opportunity to do any cleaning up before the exit

#4839920 Determine which side of a line a point is

Posted by on 25 July 2011 - 03:47 AM

It's called the perp-dot (perpendicular-dot) product; which is the exterior product in 2 dimensions. It has many properties which the cross product has in 3D; for instance | x perpdot y | = |x||y|sin theta for instance (like in 3D | x cross y | = |x||y|sin theta.

in 2D each vector (vx ; vy) has 2 perpendicular vectors (-vy ; vx), (vy ; -vx) for which we normally choose (-vy ; vx) to be the principal perpendicular, and then the perp-dot product between vectors u,v is perp(u) dot v = u.x * v.y - u.y * v.x

#4839706 Vector 2D normals

Posted by on 24 July 2011 - 01:43 PM

Generally, it will make no difference as long as you are consistent. The only times I can think in which it would make a difference is for instance computing the edge normals for a polygon; depending on the polygon winding (clockwise or anticlockwise) one normal or the other would point into the polygon or out of the polygon.

#4837929 How do I pick the correct ring when ray casting?

Posted by on 20 July 2011 - 06:28 AM

index = MathTools.Min3Index(
                    Math.Abs(Math.Min(Vector3.Dot(pointEnter, Vector3.UnitX), Vector3.Dot(pointExit, Vector3.UnitX))),      // 0
                    Math.Abs(Math.Min(Vector3.Dot(pointEnter, Vector3.UnitY), Vector3.Dot(pointExit, Vector3.UnitY))),      // 1
                    Math.Abs(Math.Min(Vector3.Dot(pointEnter, Vector3.UnitZ), Vector3.Dot(pointExit, Vector3.UnitZ)))       // 2

should be:

index = MathTools.Min3Index(
                    Math.Min(Math.Abs(Vector3.Dot(pointEnter, Vector3.UnitX)), Math.Abs(Vector3.Dot(pointExit, Vector3.UnitX))),      // 0
                    Math.Min(Math.Abs(Vector3.Dot(pointEnter, Vector3.UnitY)), Math.Abs(Vector3.Dot(pointExit, Vector3.UnitY))),      // 1
                    Math.Min(Math.Abs(Vector3.Dot(pointEnter, Vector3.UnitZ)), Math.Abs(Vector3.Dot(pointExit, Vector3.UnitZ)))       // 2

#4837891 How do I pick the correct ring when ray casting?

Posted by on 20 July 2011 - 05:28 AM

You might also first consider a simpler solution.

Back to finding the nearest plane based on intersection with sphere. The issue there was that the sphere is see-through and so when selecting part of a circle at the back of the sphere it doesn't behave intuitively; perhaps instead you should use both intersections with the sphere and take the minimum over the 3 circles with both intersections considered.

#4824745 In need of simple physics equation for distance but I can't find it anywhere

Posted by on 18 June 2011 - 02:08 AM

That is not correct.

Firing your cannon horizontally, from a height 'h' to cover a distance 'd' before hitting the ground you have: (using your syntax)

d = Vix*T
0 = h - 1/2 gT^2


T = sqrt(2h/g) and
Vix = d*sqrt(g/(2h))

g being your gravity

#4818104 Transfer of Angular Velocity?

Posted by on 31 May 2011 - 06:51 PM

If it helps to convince you, consider the wheel rotating with velocity w, and that the person is standing at a distance x from the wheel, and without loss of generality that his feet lie at distances (x-r) and (x+r) from the centre of the wheel.

given that he and his feet are stationary w.r.t to the wheel as he is not sliding, the linear velocity of the person at his centre is (wx), and the linear velocity of his feet are w(x-r) and w(x+r).
assume the person has an angular velocity of W, then the linear velocity of his feet are wx - Wr = w(x-r) and wx + Wr = w(x+r), which is iff. W = w.

#4817930 Transfer of Angular Velocity?

Posted by on 31 May 2011 - 10:47 AM

that is true yes.

#4817800 Transfer of Angular Velocity?

Posted by on 31 May 2011 - 02:39 AM

Note that if you jump from an off-center point of the platform you drift outwards because centrifugal force ceases to be balanced by friction as soon as you break contact.

Correction for OP:

If you jump from an off-centre point then you will move at a tangent to the centre (whilst spinning at same rate as before) because the centripetal force which was provided by the friction (being the force that keeps you moving in a circle) is no longer present.

#4817483 Gödelization - help needed.

Posted by on 30 May 2011 - 06:51 AM

I've not heard of Gödelization, but that just looks to be the prime factorisation of an integer for which it is quite easy to prove that a) it exists, and b) that it is unique.

An intuitive proof for existance would be:

let N be a number, either N is prime or it is not prime.
If it is not prime then there must exist a prime P and a possibly non-prime M (otherwise N would be prime).

In the same way, repeat with M instead, and eventually you either get a prime number, or 1.

from which it is easy to construct a formal inductive proof.

Proof of uniqueness is a little bit harder, a sketch proof would be:

Let N be the smallest integer expressible as the product of two minimal; non-identical sets of primes s1,s2..sn q1,q1...qm

as N is the smallest such number, then s1, and s2...sn, must have unique factorisations as they are smaller than N.
p1 then, must either divide s1, or s2...sn (or both, not important) and as all are prime, si = qj for some i,j. By removing si,qj from the two non-equal factorisations we get two smaller, equal numbers. as they are smaller than N, by assumption they have unique factorisations and so the two factorisations cannot be different.

#4803500 acos vs cos

Posted by on 27 April 2011 - 05:57 AM

acos (mathematicaly normally written as cos^-1 x with the -1 as superscript) is the inverse map for cos. acos is a multivalued function technically, y = acos(x) has infinite solutions for y, but we normally take the principal branch restricting it's solutions to the range -pi to pi. therefore for angles 'x' (radians) in the range -pi to pi. acos(cos(x)) = x, and for values 'y' in the range -1 to 1. cos(acos(y)) = y.

the angle between two vectors (not points) can be easily found by the inner product <x,y> = |x||y|cos(t), rearranging to give t = acos(<x,y>/(|x||y|))

the choice of the branch cut for acos means that the value 't' found above for the angle between two vectors is the smallest such angle, it's easy to see that equally t + 2*n*pi for integer n are also solutions to the original equation <x,y> = |x||y|cos(t)

#4802659 How do you pick an edge?

Posted by on 25 April 2011 - 08:06 AM

It would suffice to simply find the closest edge to the cursor-ray, choosing those less than your epsilon; if you like you'd be intersecting your cursor ray with capsules that contain each edge as you do with spheres that contain your vertices.

probably what could be even better (and far simpler), is to simply find the first intersected triangle, and evaluate if the intersection point is close to an edge/vertex to choose those instead of the triangle face. if you needed to have wireframe; having triangles with no solid faces too, then you could simply continue along ray if you intersect a triangle which has no face, and the intersection point is not sufficiently close to the edges/vertices.

in both cases you can project the intersection point onto the given edge/vertex to get a picking point on the feature if needed.

my second proposed method would likely be much more easily transformed to make the 'thickness' of the edge/vertex be screen-space constant which would probably be far preferable as then the distance from cursor to the visual representation of the edge/vertex required to select it wouldn't become too large as edge/vertex approaches near clip-plane, or too small to be able to reliably select the edge/vertex if it moves very far away from the camera.