BBC BASIC « Trigonometry Woes... » Welcome Guest. Please Login or Register.Mar 31st, 2018, 10:43pm

ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
 Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi) BBC BASIC Resources BBC BASIC Help Documentation BBC BASIC for Windows Home Page BBC BASIC Programmers' Reference BBC BASIC Beginners' Tutorial BBC BASIC for SDL 2.0 Home Page BBC BASIC Discussion Group

 BBC BASIC Programming BBC BASIC Language (Moderator: Richard Russell)  Trigonometry Woes... « Previous Topic | Next Topic »
 Pages: 1
 Author Topic: Trigonometry Woes...  (Read 202 times)
jimcroisdale
New Member

member is offline

Posts: 4
 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 )

Any clues?

Cheers,

Jim

 Logged

jimcroisdale
New Member

member is offline

Posts: 4
 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
 Logged

Richard Russell

member is offline

Posts: 803
 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 » Logged

jimcroisdale
New Member

member is offline

Posts: 4
 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
595 ANGLE = ASN(OPPOSITE/HYPO)
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?
 Logged

Richard Russell

member is offline

Posts: 803
 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.
 Logged

jimcroisdale
New Member

member is offline

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

Haha, yes! Just figured that out myself!

All working now - thankyou!
 Logged

 Pages: 1
 Forum Jump ------------------ => General ------------------ - General Board - Announcements - Support and Promote ------------------ => Development ------------------ - Interpreter & Run-Time Engine - Integrated Development Environment - Linux (86) - Mac OS-X - Android - Raspberry Pi - iOS ------------------ => Programming ------------------ - BBC BASIC Language - Operating System Interface - VDU Emulation - Libraries - Assembly Language - Communication and Input/Output - Database and Files - Graphics and Games - Sound, Music and Video - User Interface « Previous Topic | Next Topic »

| |