Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Too dumb to do the maths

Author
Message
Qweeg
20
Years of Service
User Offline
Joined: 23rd Sep 2004
Location: Kent
Posted: 1st Sep 2005 23:52
Apologies as I am sure this is simple, but I have been thinking about it for too long, and now I have a total blank.

I have 2 angles and I just need to know how close they are to being at right angles to each other. The angles could be positive or negative, but I am just need to return a value between 0 and 90.

Any help would be much appreciated
Louiz ofRohr
19
Years of Service
User Offline
Joined: 11th Nov 2004
Location:
Posted: 2nd Sep 2005 04:24 Edited at: 2nd Sep 2005 06:29
Hi..

I really can't understand what you want..
Oh.. do you want to know the difference between 2 angles?

It could be:

absolute value of(angle2 - angle1)


-------------------------------------------------

ok..

Quote: "absolute value of(angle2 - angle1)"

lets think angle2=10° and angle1=70°;
angle2 - angle1 = -60°
|-60°| = 60°
So the distance between these angles is 60°
(if they are rotating around the same centre, of course)


Example2:
You have two 30° angles;
you wanna know what is left for the angles do *collision..

The centre of the *sharp angle above is X, being:

|(limitangle1 - X)| + |(limitangle2 - X)| = 30°

so the angular distance between two *sharp angles' areas
is the shortest angular distance between 2 limits (not of the
same angle, because |limitangle1 - limitangle2| = fullanglearea)


Don't worry, this math is not of the most easy..
But you can learn it practising

Sorry if you couldn't understand the explanation, but this
is how I understand.. And I think it is the most easy way..

was it what you wanted?

anyway.. hope it was useful

The worst foe lies within the self..
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Sep 2005 18:22
Louiz is right, you need to explain the problem a bit more.

In simple terms, an angle is an arc between two lines - each line radiating from a single origin point.

The direction each line is pointing is in degrees. So, let's say each line was on a clock face and it was 9pm. The minute hand would be at 0 degrees and the hour hand would be 90 degrees.

Alternatively, if you have a single line, it can be described as being rotated a number of degrees from 0 (12 O'clock). The first line isn't there so it's assumed. If it isn't, then there's no reference point to calculate the angle of rotation.

You say you "have 2 angles". Do you mean you have 2 lines which make up an angle? If so, then as Louiz says, ABS(Angle1-Angle2) will give you the angle of the arc between the two lines.

ArcAngle-90 will then give you the difference between the angle you have and a right-angle which is what I think you are after. If the result is less than zero then your angle is less than 90 degrees and if it is greater than zero then your angle is greater than 90 degrees.

If your arc angle is exactly 90 degrees then it will return zero. Eg:

LineAngle1 = 20
LineAngle2 = 90
Rem (Angle of arc is 70 degrees)

ArcAngle = ABS(LineAngle1-LineAngle2): Rem Returns 70
AngleDiff = ArcAngle-90: Rem Returns -20

The -20 returned means that your angle is 20 degrees less than 90 degrees. If it returned 20 then it would mean you angle is 20 degrees bigger than 90 degrees.

TDK_Man

Qweeg
20
Years of Service
User Offline
Joined: 23rd Sep 2004
Location: Kent
Posted: 2nd Sep 2005 19:39
Sorry guys - it was probably as clear as mud to anyone but me.

This is to do with collisions and elasticity really, so maybe it will be clearer with an example:

If a moving ball (cue ball for example) collides with a static one, and the cue ball has backspin applied, then depending on how full the impact is depends on how much the backspin will affect the subequent motion of the cue ball.

What I mean is that if the balls strike head on then the cue ball would move backwards after the collision. However if it were to just strike a glancing blow, the effect of backpin would be minimal and the ball would continue to move forwards.

Looking at things in this way the moving ball can effectively strike the other ball at an angle between 0 and 90(+/-) degrees - with 0 being a head on collision and 90 being the faintest of glancing contacts.

But obviously the angle between the balls on contact and the angle the moving ball is travelling at can both be any angle, so I need a way to convert the difference into a 0-90 range.

Hopefully this makes it a bit clearer. As you may guess this relates to a pool game. I have all the effects of sidespin and top and backspin working (albeit in a 'fake' physics way), except for taking into account how the speed of the cue ball is altered by the fullness of the contact.

Having played about with things this seems to work:



However I haven't used ArcAngle before so am going to have a look at this now. Thanks for your help guys - and sorry for not posting something a little clearer in the first place.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Sep 2005 03:17
Just to confirm: ArcAngle is just a variable name I used in my example - not a function of DB.

Your function doesn't look right to me - you are returning the variable temp, although earlier, you only assign a value to the variable temp#.

The first use is floating point and the second is integer and would just return zero. You are doing the same with the other variables - mixing integer and floating point versions.

Also, I'm not a DBP user, but the use of return looks decidedly dodgy to me.

I would use:



But I'm quite happy to be corrected by a proper DBPro user!

TDK_Man

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Sep 2005 03:43
Actually, having re-read your last post again, I'm now not so sure that your reasoning is correct with regards to the angles.



If A is the start point, B is head on, C is a glancing left contact and D is a glancing right contact, then E is the angle you are working on and I can't see where 90 degrees comes into it.

I would have thought that what you needed was a deviation percentage hit value where a dead centre hit was 0%.

The only thing I can suggest is that you draw a line dead centre of the ball being struck to dead centre of the ball being aimed at and call that angle zero degrees as a reference.

Then, assuming a collision takes place, the angle the ball was struck would give you the deviance percentage off the direct hit line - allowing you to make the calculation you need.

Sorry, but this is the only thing I can suggest.

TDK_Man

Louiz ofRohr
19
Years of Service
User Offline
Joined: 11th Nov 2004
Location:
Posted: 4th Sep 2005 18:39
Quote: "Sorry, but this is the only thing I can suggest."


Good explanation, TDK
Actually few people understand what I explain

The worst foe lies within the self..

Login to post a reply

Server time is: 2024-09-24 03:14:58
Your offset time is: 2024-09-24 03:14:58