
-----------------------------------
Martin
Sat Apr 26, 2003 11:37 am

Sine inverse
-----------------------------------
Is there any way I can use sine inverse with turing? My problem is this:

I know the starting and ending points of a line, and I need to find the angle formed...ex:

                   (x2,y2)
               / |
             /   |
           /     |
         /       |
(x1,y1)/ m___|__


solving for angle m

bleh the diagram's not too great, but I'm sure you get the idea

-----------------------------------
JSBN
Sat Apr 26, 2003 12:20 pm


-----------------------------------
u could use cos or sin ratio to figure it out, there is a tutorial for it.
and if u need the length of the angled line u could use pythagorium thyrum: A^2 + B^2 = C^2

-----------------------------------
octopi
Sat Apr 26, 2003 1:08 pm


-----------------------------------
Had one way, but this ones much better.


function arcsin ( x : real ) : real 
  if (x = 1) then
     result 90 
  else 
     result arctand(sqrt(abs((x*x) / (1 - (x *x))))) 
  end if
end arcsin 

function arccos ( x : real ) : real 
  if (x = 0) then
     result 90 
  else 
     result arctand(sqrt(abs((1 - (x *x)) / (x *x)))) 
  end if
end arccos 

for i:1..90 
   put arccos(cosd(i)) .. 
   put " " .. 
end for

--Modified it to work with 1, and 0

-----------------------------------
jamez
Sat Apr 26, 2003 7:54 pm


-----------------------------------
octopi your code crashes :P

-----------------------------------
octopi
Sat Apr 26, 2003 8:10 pm


-----------------------------------
Not for me, what version do you use, and are you modifying it at all?

I test in winoot 3 only.

-----------------------------------
nate
Sat Apr 26, 2003 8:15 pm

math
-----------------------------------
The reason its crashin is cause when you reach 90 degrees. 
It messes up cause your dividing by 0. 

Basically you don't you arcsin or arctan for something that is at 90 degrees?

???
Well, i am only in grade 9 so how do i know? (thats what i think)
???

-Nate

-----------------------------------
Tony
Sat Apr 26, 2003 8:15 pm


-----------------------------------
Nate is right, but you need a function that works for 360+ degrees

so all you have to do is place a guard in the function...

function arcsin ( x : real ) : real 
if x*x not= 1 then
  result arctand(sqrt(abs((x*x) / (1 - (x *x))))) 
else
    result 90
end if

end arcsin 


although it still outputs a weird number instead of 0. I suppose it has something to do with the fact that its impossible for arcsin to be 0 :?

-----------------------------------
octopi
Sat Apr 26, 2003 9:04 pm


-----------------------------------
The weird number isn't that weird....
its:

1.207418 raised to the  -6
(also known as)
 0.000001207418
So virtually zero.
