BBC BASIC
« Trigonometry Woes... »

Welcome Guest. Please Login or Register.
Jan 23rd, 2018, 7:05pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Trigonometry Woes...  (Read 107 times)
jimcroisdale
New Member
Image


member is offline

Avatar




PM


Posts: 4
xx Trigonometry Woes...
« Thread started on: Dec 18th, 2017, 3:34pm »

Hi all,

Using BBC BASIC for Windows, evaluation version.

Trying to get one of the angles in a right angled triangle. I know the length of all three sides (two being user inputs and the hypotenuse being worked out from those using Pythagoras).

So just need a line of code that works to give me one of the angles (other than the right angle smiley )

Any clues?

Cheers,

Jim

User IP Logged

jimcroisdale
New Member
Image


member is offline

Avatar




PM


Posts: 4
xx Re: Trigonometry Woes...
« Reply #1 on: Dec 18th, 2017, 4:07pm »

To expand, I have three variables:

OPPOSITE - length of the side opposite the angle i want to calculate
ADJACENT - length of the side next to the angle i want to calculate
HYPO - the hypotenuse

So I need some code that will work out the variable"ANGLE".

regards,
Jim
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 692
xx Re: Trigonometry Woes...
« Reply #2 on: Dec 18th, 2017, 4:25pm »

on Dec 18th, 2017, 4:07pm, jimcroisdale wrote:
So I need some code that will work out the variable"ANGLE".

Back more years than I care to admit, the 'helpful' mnemonic was OHMS: Opposite over Hypotenuse Means Sine (well, helpful if you knew that Ohms was the unit for resistance I suppose, or was it On Her Majesty's Service?).

So it follows that you need inverse-Sine (ASN) to get back to the angle:

Code:
      ANGLE = ASN(OPPOSITE / HYPOTENUSE) 

Though since you say you know all three sides you can equivalently use:

Code:
      ANGLE = ACS(ADJACENT / HYPOTENUSE) 

or:

Code:
      ANGLE = ATN(OPPOSITE / ADJACENT) 

Richard.
« Last Edit: Dec 18th, 2017, 4:38pm by Richard Russell » User IP Logged

jimcroisdale
New Member
Image


member is offline

Avatar




PM


Posts: 4
xx Re: Trigonometry Woes...
« Reply #3 on: Dec 18th, 2017, 4:35pm »

Thankyou for the reply! I've addded that in but it doesnt seem to work.

490 PRINT " Ackermann Angle Calculator"
500 PRINT " **************************"
510 PRINT '
520 INPUT " Enter Distance Between Kingpins in MM: " TRACK
530 INPUT " Enter Distance Between Front and Back Axle in MM: " LONG
540 ADJACENT = TRACK / 2
550 OPPOSITE = LONG
560 HYPO = SQR((ADJACENT*ADJACENT)+(OPPOSITE*OPPOSITE)) REM Pythagoras Bit!
595 ANGLE = ASN(OPPOSITE/HYPO)
600 PRINT ADJACENT
610 PRINT OPPOSITE
620 PRINT HYPO
630 PRINT ANGLE

I'm running the program and entering the sides as 500 and 500. it's working out the hypo to 707 which is right. But then the angle (which should be 45deg) is coming out at 0.785.

Any ideas what I'm doing wrong? smiley
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 692
xx Re: Trigonometry Woes...
« Reply #4 on: Dec 18th, 2017, 4:40pm »

on Dec 18th, 2017, 4:35pm, jimcroisdale wrote:
But then the angle (which should be 45deg) is coming out at 0.785. Any ideas what I'm doing wrong?

Nothing. 0.785 radians is approximately 45 degrees:

Code:
      ANGLE = DEG(ASN(OPPOSITE/HYPO)) 

Richard.
User IP Logged

jimcroisdale
New Member
Image


member is offline

Avatar




PM


Posts: 4
xx Re: Trigonometry Woes...
« Reply #5 on: Dec 18th, 2017, 4:40pm »

Haha, yes! Just figured that out myself! smiley

All working now - thankyou!
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls