# SPuntte

Member

20

158 Neutral

• Rank
Member
1. ## Determining whether angle is in given range

DUDE! Thanks, a lot, it works :] That was less complicated than I thought. Maybe I messed things up already in the beginning as I tried to implement it using angles in range ]-π, π] (What I really measure here is an angle from a vector to another so the clockwiseness is significant. That's why I wanted to keep it signed.). Now as you used range [0, 2π[ everything was a lot easier to figure and you explanation was excellent and simple. Thank you one more time.
2. ## Determining whether angle is in given range

It is confusing, to me as well :S I think the reason of my problem is the periodic nature of angles. If angles weren't periodic the solution to this problem would be as easy as checking whether (rightAngle < currentAngle && currentAngle < leftAngle) is true. However, any virtually equal angles a and b may be different since a ≡ b mod 2π. On the other hand, this means, that any angle beyond interval [0, 2π[ will be transformed into that interval. And that is what makes the problem hard to solve. Consider the following case: rightAngle = 60° leftAngle = 390° (= 360° + 30°) currentAngle = 180° This should yield the result 'in range', however the computer sees leftAngle as 30° and the simple check described above won't work. I think adding ±360° to one of the three angles should make it solvable as beore. Only problem is to determine the angle that needs tweaking. I don't care if the solution applies simple binary comparsion with angles, vector math or any other method. As long as it works and is optimized I'd love it :) fng: Since leftAngle can be (virtually) less than rightAngle, that assert-macro must not be used. The Variables rightAngle and leftAngle can hold any values. Only constraint is that the 'in range'-arc is measured ccw from rightAngle to leftAngle.
3. ## Determining whether angle is in given range

This keeps bothering me. I tried the method of perpendicular vectors but discovered almost instantly that it won't work in case of an 'in range'-arc with the central angle smaller than π radians (180 degrees). Maybe my first post was unclear but the angle can be anywhere in ]0, 2π[. I still need more ideas to solve this. Thanks in advance!
4. ## Determining whether angle is in given range

I didn't even think about anything like that :O unfortunately, that sounds a bit slow for my purposes as this will used for a kind of "angle constraint" in a constrained verlet dynamics scheme. I've come this far: outOfRange = True If leftAngle < 0 And rightAngle >= 0 Then If currentAngle < 0 Then If currentAngle + 360 > rightangle And currentAngle + 360 < leftAngle + 360 Then outOfRange = False EndIf ElseIf currentAngle + 360 > rightangle And currentAngle < leftAngle + 360 Then outOfRange = False EndIf ElseIf currentAngle > rightAngle And currentAngle < leftAngle Then outOfRange = False EndIf The only case it fails is when left and right hand side angles of the arc are both negative. o.O
5. ## Determining whether angle is in given range

For some reason I happen not to succeed - still after several attempts - in implementing a bulletproof algorithm for solving the following problem: What I know are the limiting angles of an arc. What I want to know is if a given third angle is in that arc. All angles are wrapped to range -π < angle =< π. Of course, the sides of the arc are distinguishable from each other so it matters in which order they are given. Positive angle direction is counterclockwise. Here's a helper pic Can anyone pwn this, thx? :)
6. ## Angle between vectors

Quote:Original post by alvaro Since I recently suggested using complex numbers for 2D geometry in another thread, let me explain what you would do for this problem. Think of your two vectors as complex numbers z1 and z2. The angle you seek is arg(z1/z2). Multiply by 180/pi to convert to degrees and you are done. This does the same as the algorith haegarr described. The problem is that arg(z) ∊ ]-π, π]. So in case of negative argument the angle is 2π - arg(z).
7. ## Finding Tangent vectors for a cubic spline.

What alvaro said is true. If you are unsure how to extract the tangent vector from the derivative, you should check this similar problem. Pay attention to the fact that there's actually two (left- and right-hand) normal vectors for an arbitrary point on a continuous 2D-curve.
8. ## Indefinite integral I can't figure out

There's no way to integrate that analytically. You have to either do it numerically or approximate the gaussian density function with some simpler function or series like the Taylor expansion. You can read more about the "error function" here.
9. ## magnetic moment of a moving charge

Quote:Original post by taby Darn. I was finally starting to convince him, I could feel it! :) I hope he goes to physicsforums. There you simply get banned on the spot for questioning relativity, even if you do it nicely. I don't agree with that kind of militant stance by default. It smacks of insecurity and ignorance on both sides of the conversation. Sure we got a little testy here and there (well, I did anyway), but at least we were willing to listen first. I learned something very sneaky about science during this conversation. I wouldn't have learned it without victor's assistance. It seems to me that the only way to strengthen one's theory is to doubt it, and from every single angle of attack imaginable. It's only by explicitly resolving these doubts head-on that the theory can become strong. I hope victor learns to doubt himself someday. Then he'll finally be a great thinker that is truly capable of proving the usefulness of his models. At the very least, I think we've all given him reason to continue to prove his model. I honestly think he's in it for the science. He just doesn't know how science works, yet. I've been there before, and still am in ways. It's frustrating as all hell. Yeah, first this desperate effort to convince him to admit that he hadn't got quite right understanding about modern physics seemed to be in vain. But I agree with taby. Me too have learned something - not only about doing science but also about psychology and in fact the essence of electromagnetism too ;). What comes to "kind of militant stance" of physicsforums, I think it's mainly because there's always that part of ppl that thinks it's funny to mess things up on some forum by trolling. By questioning relativity and pretending to be serious about it. Though, I don't think Victor was probably a troll. In fact, simply denying all kinds of attempts to doubt existing scientific facts is called dogmatism. However, I think it's better for physicsforums itself to be dogmatic because of all those jerks on the net. Whether or not the international community of science is dogmatic, is whole another question. I think it's not.
10. ## Finding the normal of a point on a sine wave

Oh, I accidentally read the parentheses wrong. Dave's formula is alright. However, I understood that only the amplitude of sin was modified, not it's periodQuote:Original post by Atrix256 since a sine wave itself doesn't look like realistic waves, i multiple the output of sin by 0.125 to make it 1/8th as tall of a wave. So knighty's formula is calculated right but unfortunately it's not the one we're looking for hereQuote:Original post by knighty Now if I've understood well you have: f(x)=sin(a*x) Substituting the correct(?) fuction to knighty's formula yields: whete t is the scaling multiplier (= 1/8 ?) #EDIT: It seems that the formula above calculates the right-hand normal that points "inside" the wawes. To calculate the left-hand normal vector (which has positive y-component) you should just multiply the components by -1.
11. ## Finding the normal of a point on a sine wave

I'm not sure whether Dave's formula is right. It might be, then i just misunderstood it. Here's how I do that: We have a scaled sine function, t sin x Now we differentiate it with respect to x so we get: D(t sin x) = t D(sin x) = t cos x From analytic geometry we know that slope of a tangent of a function (derivative) and it's direction angle a satisfy the relation: tan a = k So we have: tan a = t cos x Solving for a: a = arctan(t cos x) Now we have the direction angle which unambigiously defines an unit length tangent vector s: s = i cos a + j sin a Knowing the tangent it's easy to get the normal: n = -i sin a + j cos a So the normal parametrizes as (-sin a, cos a) where a = arctan(t cos x) Someone correct me if I did something wrong :)
12. ## Camera space to world space

Ok, keep in mind that it matters in which order the transforms are applied. To make things even more complicated, you should also remember that with row vector matrices everything works in opposite order compared to column vector matrices. I now assume that you're using purely column vector matrices. As the translation (ie. your camera has position p=[5, 5, 0]) takes place in global coordinates (not in rotated camera coordinates) it should take place first. With column vectors martix transforms cumulate from left to right. That means your transform to camera space looks like , T and R being the separate translation and rotation matrices. By multiplying the equation with the inverse of M we get We also know that and which yields Concluding those above we finally get Fortunately, that's the very same method you suggested. So the translation is negative of the original and it's done after inverted rotation.
13. ## Camera space to world space

Right... hopefully I do not mess the things up any more. I suggest to check this: http://www.gamedev.net/community/forums/topic.asp?topic_id=547776 So as it seems you treat vectors as columns. That means your transform should look like , where is the transformed point, is the transformation matrix and the point being transformed. So in case of column vectors a Matrix is multiplied by a vector. What comes to transforming back to the original coordinate system, it's just like the original trasformation, but the matrix is now the inverse of the original. Like at this: Wheter the inverse matrix is easy to calculate depends on the transformation. If it's orthogonal, the inverse is simply the transpose of the original. The second problem occurs because your 4*4 matrix seems to be meant for row vectors and you're multiplying it with a column vector. Just transpose the matrix and everything will work fine.
14. ## magnetic moment of a moving charge

Hey guys, thak you! You've somewhat changed some of the principles how I perceive electromagnetics. I'm still kind of puzzled with that retarded-relativistic-stuff and how to apply it in practice, but this is a good start already. Victor-Victor, according to your latest post, I think you're thinking electromagnetics too much as a dualistic phenomenon. The problem is, that there aren't such independent things as electric interaction and magnetic interaction. They can't be fully separated from each other. Like in the case of two parallel electron beams we noticed, the nature of the interaction depends on our reference frame. E and B fields are just two sides of the same thing. Maxwell's equations are well-known to require special relativity due to finite speed of light: It means that E transforms into B - and vice versa - under a Lorentz transformation. In conclusion, the aswer to both of these: >>A.) Will there be *magnetic* attraction between parallel electron beams? YES/NO >>B.) Will there be *magnetic* repulsion between parallel electron beams? YES/NO can't be defined. The real thing is electromagnetic attraction or repulsion. Not just electric or magnetic. P.S. @ Kambiz: I didn't quite understand how to implement a simulation using those retarded variables. Could you light that up a bit? #EDIT: According to Wikipedia I understood that "Biot-Savart law for a point charge" is the following pair of equations: But in the same article, there's a form given with corrections for relativistic speeds: So what's this? Is Biot-Savart just an approximation of the former ones when , or what? And what's the actual difference beetween those and Liénard-Wiechert potentials? [Edited by - SPuntte on October 19, 2009 6:13:36 AM]
15. ## magnetic moment of a moving charge

I have a simulation where charged particles move in a plane (let's say, in the xy-plane). I calculate the forces between them with Coulomb's law, which in fact isn't rigth as the charges are moving. I'd like to correct my simulation by adding magnetic interaction. So I got an idea of calculating the magnetic moments of the moving particles. When I know the magnetic moments I can calculate the z-component of the B-field in an arbitrary point of my simulation plane. Now I now E and B so I can use Lorenz force to simulate the movement of the particles. Only problem is the calculation of the magnetic moment. Maybe someone with more experience could derive it from Maxwell's equations?