Recent

Author Topic: Law of Sines through Free Pascal  (Read 4846 times)

Orestaklos

  • Newbie
  • Posts: 4
Law of Sines through Free Pascal
« on: April 07, 2015, 09:46:39 am »
Hey all,

I've started learning the FreePascal through Lazarus and I recently bought some books with exercises on it.
I've been coping for 1 week with the Law of Sines but without result.
The writen program is below attached.

I would appreciate it, when you have a look.
Thanks.

Nitorami

  • Hero Member
  • *****
  • Posts: 605
Re: Law of Sines through Free Pascal
« Reply #1 on: April 07, 2015, 11:05:13 am »
Hi Orestaklos

What is the problem ? When compiling, the compiler takes you directly to the incorrect lines:

1.
Code: [Select]
resdegB:=arcsin(radtodeg(0,99));
0,99 is not a valid number, the compiler thinks you passed two parameters. Try 0.99.

2. getresdegB should be called Trig2.getresdegB

If I fix these, it works for me.

Note - you do not need the C style brackets as in
function getpart4():single;

Simply use
function getpart4:single;




« Last Edit: April 07, 2015, 11:10:36 am by Nitorami »

Orestaklos

  • Newbie
  • Posts: 4
Re: Law of Sines through Free Pascal
« Reply #2 on: April 07, 2015, 05:36:02 pm »
Oh that was great!
I corrected it as you have mentioned and it works!

Thank you a lot! :)

Orestaklos

  • Newbie
  • Posts: 4
Re: Law of Sines through Free Pascal
« Reply #3 on: April 07, 2015, 06:33:16 pm »
hm.. :-\
something goes wrong, the result comes to 0.02 instead of 81.89

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Law of Sines through Free Pascal
« Reply #4 on: April 07, 2015, 07:12:19 pm »
Without thinking of deeper semantics, shuffling functions around gives what you expect:

Code: [Select]
resdegB:=radtodeg(arcsin(ressinB));
Code: [Select]
Result for B=sin^-1(0,99)= 81,89
Ok, if i recall the arcsin doesn't take angle for parameter, it returns one. Also all functions work as radians, therefore the returned angle must be converted to degrees.

Nitorami

  • Hero Member
  • *****
  • Posts: 605
Re: Law of Sines through Free Pascal
« Reply #5 on: April 07, 2015, 07:24:16 pm »
Of course. It makes no sense to apply radtodeg or degtorad to the argument of arcsin, which is not an angle but a number between -1 and +1.

The result of arcsin() is an angle. It is in radians, and can be converted to degrees by radtodeg (and not degtorad!).

mas steindorff

  • Hero Member
  • *****
  • Posts: 565
Re: Law of Sines through Free Pascal
« Reply #6 on: April 07, 2015, 08:45:15 pm »
Note - you do not need the C style brackets as in
function getpart4():single;

Simply use
function getpart4:single;
but the "()" do aid in code review telling the human reader that "getpart4" is a function, not a variable. it's not like your saving any keystrokes with autocompletion enabled...
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

Orestaklos

  • Newbie
  • Posts: 4
Re: Law of Sines through Free Pascal
« Reply #7 on: April 17, 2015, 08:47:47 pm »
Thank you all for your great help!
I try my best to understand the language and with your help it makes it easier. :)

 

TinyPortal © 2005-2018