Are any of these available in normal Quest or are there any libraries for them?

I heard that they are...

But... it is in radians and not degrees so it needs to be tweaked...

I don't remember who posted this. It definitely didn't come from me.

(I'm also not certain that it works.)

```
<function name="calculateSin" parameters="angle, precision" type="int"><![CDATA[
// If you're trying to work out the horiz/vert components of moving some distance, then
// `distance * calculateSin (angle, distance)` will give an answer accurate to the
// nearest square.
if (precision > 1) {
precision = 1 / (2*precision + 1)
}
result = 0
power = 1
numerator = angle
sign = 1
factorial = 1
while ((numerator / factorial) > 0.000001) {
result = result + (numerator * sign / factorial)
numerator = numerator * angle * angle
factorial = factorial * (power+1) * (power+2)
power = power + 2
sign = 0 - sign
}
return (result)
]]></function>
```

I thought I tried sqrt(4)... !!!

Maybe I had Sqrt(4)...

I hate how case sensitive Quest it!!!!

OK, I got the calculateSin to work...

But the answer does not make sence...

I did the same, `Sqrt(4)`

, then cursed. (Hehehe.)

I have no clue where I found `calculateSin`

.

Did you feed it the angle in radians? (I think I got the code from that thread. I remember the radians VS angle conversation, but not how long ago it was (or what the thread was about).)

I used:

msg ("the calculated sine of 45 at a distance of 10 spaces is " + calculateSin (45, 10, 1))

and got:

the calculated sine of 45 at a distance of 10 spaces is 1526351

I'm sure what ever the answer is... it is incorrect...

(No, I did not convert to radians)

using sin, cos, and tan with radians works

Rock on.

@DL

Do you remember that thread?

I think there was talk of space travel, and I was confused at one point as to what measurement you were referring...

("...to what measurement you were referring..." Yeah... That's what happens when I don't end my sentence in a preposition.)

...like MACH 5 or something?

I hate how case sensitive Quest it!!!!

Usually it us, but not in this case!

I have added a bit to the page in the docs listing functions to note that these functions do exist (I am not going to give each its own page).

http://docs.textadventures.co.uk/quest/functions/

If it's in the code somewhere, where???

I would like to modify it so that the functions accept input in degrees, which people use, and not convert to radians to use it...

(Still don't understand why anyone would really use radians...)

Yes, I would like 1/2 pi of that apple pie...

Sure, I know how to get there... turn to a heading of pi/2 for 33 yards, then go pi^2 for 23 pi feet, turn pi/8 for 1 mile...

As far as case sensitivity goes, DL and I must have both had typos or something.

I could have sworn I tried `msg(Sqrt(4))`

before `msg(sqrt(4))`

, with the former throwing an error and the latter outputting 2, but:

```
msg("a = Sqrt(4)")
a = Sqrt(4)
msg("msg(a)")
msg(a)
msg("b = sqrt(4)")
b = sqrt(4)
msg("msg(b)")
msg(b)
msg("msg(Sqrt(4))")
msg(Sqrt(4))
msg("msg(sqrt(4))")
msg(sqrt(4))
```

DL, they are hard-coded so you cannot see them or override them. You would need to create a new function with a new name (eg "Sine", "Cosine" and "Tangent"). For Sine, the code would be:

```
return (Sin(angle * pi / 180))
```

Radians are used because they are more fundamental. The 360 degrees in a circle is an arbitrary number made up by the Babylonians, whilst aliens from another star will use radians (by whatever name). If you use these functions in calculus then you have to use radians. Neither of these reasons may be compelling for you...

What would made sense is to have two functions, one for degrees and one for radians, but the designers of .NET decided otherwise, and their use in Quest is so obscure I have no plans to add them myself.

That is the problem with floating point arithmetic. It is accurate to 1 part in 10^16, which is pretty damn good, but the errors canappear.

Be careful using round, as Cos ranges from -1 to 1, so if you round to a whole number, you will only get -1, 0 and 1.

But you should not need to round when actually using it. For the space flight mentioned earlier, if you calculate the change in position along one axis, it is good enough.

I have an Atari 800, with Basic and had the option of setting the computer in:

Radians, Degrees, or Gradians...

(It was a command I could use at the start of the program...)

Gradians would be like a metric version of degrees.

Instead of 360 degrees in a circle, there would be 400.

True, if the aliens used "degrees" it would be based on their own planet and star system.

We have degrees because that is the amount the night sky moves per night...

I know, 360 in a circle, but 365 days in a year...

Some time, in human history, after determining the degrees in a circle and days in a year, something happened to the Earth resulting in a slowing of the spin, and/or a change in the distance to the Sun...

Which added 5 days to the year, otherwise, a circle would have 365 degrees...

(FYI... A Marsan circle has 669 degrees...)

I have an Atari 800, with Basic and had the option of setting the computer in: Radians, Degrees, or Gradians...

Now you mention it, I have used a version of BASIC that does that long ago. Given BASIC has developed into Visual BASIC on .NET, kind of odd it lost that along the way.

Some time, in human history, after determining the degrees in a circle and days in a year, something happened to the Earth resulting in a slowing of the spin, and/or a change in the distance to the Sun...

More likely they mis-calculated, assuming it must be a nice, neat number, given the world was created byt the gods. What god creates a world where there are 365.2422 days in a year?