SRL Archive - Bugs

Tan(e: Extended): Extended;


ReadySteadyGo

2010-07-24 19:50:03

Please add.

Nava2

2010-07-24 21:18:17

do sin(e)/cos(e) :D

Thats all that tan is anyways!

ReadySteadyGo

2010-07-24 21:28:55

Cheers Nava! Shows how much I've forgotten in a year without maths :P

It should probably be added anyway for noobies like me.

Edit: Radians is missing in Simba as well.

I have a temp fix but would be nice :)

edit: if you want to just slot these in:

function Tan(e: Extended): Extended;
begin
Result := sin(e) / cos(e);
end;

function Radians(e: Extended): Extended;
begin
Result := e * 180 / Pi;
end;

Nava2

2010-07-24 22:15:32

I believe there is already a Tan in FPC, which could probably be used, and the radians function as well. I was more or less just suggesting a hack.

Uh.. I'll let Wizzup do this.. :D

Gu3st...

2010-07-25 03:40:09

Yeah.. uhm.. Last time I asked Wizzup? to add it (Radians(); ) he told me to do e * 180 / Pi
But I still vote yes for these to be added, along with Degrees();

Nava2

2010-07-25 11:00:25

I think this could just be added into simba.simba or w/e it is in SRL.

(Not tan though..)

Wanted

2010-07-25 12:44:03

While you're at it

GetApplication.MessageBox

function ArcTan(X: Extended): Extended;
The ArcTan function is a mathematical function giving the value in radians of the Arc Tangent of X.

function ArcSin(X: Extended): Extended;
The ArcSin function is a mathematical function giving the value in radians of the Arc Sine of X.

function ArcCos(X: Extended): Extended;
The ArcCos function is a mathematical function giving the value in radians of the Arc Cosine of X.


function Cotan(X: Extended): Extended;
1 / tan(X), X <> 0

function Secant(X: Extended): Extended;
1 / cos(X)

function Cosecant(X: Extended): Extended;
1 / sin(X)

function Hypot(X, Y: Extended): Extended;
Sqrt(X**2 + Y**2)

function Cot(X: Extended): Extended;
Alias for Cotan.

function Sec(X: Extended): Extended;
Alias for Secant.

function Csc(X: Extended): Extended;
Alias for Cosecant.

function Cosh(X: Extended): Extended;
Hyperbolic cosine.

function Sinh(X: Extended): Extended;
Hyperbolic sine.

function Tanh(X: Extended): Extended;
Hyperbolic tangent.

function CotH(X: Extended): Extended;
Hyperbolic cotangent.

function SecH(X: Extended): Extended;
Hyperbolic secant.

function CscH(X: Extended): Extended;
Hyperbolic cosecant.

function ArcCot(X: Extended): Extended;
Inversed cotangent.

function ArcSec(X: Extended): Extended;
Inversed secant.

function ArcCsc(X: Extended): Extended;
Inversed cosecant.

function ArcCosh(X: Extended): Extended;
Inversed hyperbolic cosine.

function ArcSinh(X: Extended): Extended;
Inversed hyperbolic sine.

function ArcTanh(X: Extended): Extended;
Inversed hyperbolic tangent.

function ArcCotH(X: Extended): Extended;
Inversed hyperbolic cotangent.

function ArcSecH(X: Extended): Extended;
Inversed hyperbolic secant.

function ArcCscH(X: Extended): Extended;
Inversed hyperbolic cosecant.

function LnXP1(X: Extended): Extended;
Return ln(1 + X). Accurate for X near 0.

function Log10(X: Extended): Extended;
The Log10 function returns the logarithm to base 10 of X.

function Log2(X: Extended): Extended;

function LogN(Base, X: Extended): Extended;

function Exp(Number: Extended): Extended;
The Exp function takes an integer or floating point Number and raises e (2.72) to that power.

function Factorial(number: Int64): Int64;
Returns the factorial (!) of number.

function BinCoe(a, b: LongInt): Extended;
Returns the binomial coefficient of a and b (a over b).

function Degrees(Radians: Extended): Extended;
Returns radians in 0-360 degree form.

function Radians(Degrees: Extended): Extended;
Returns the degrees in 0 to 2Pi radian form.

function Inversus(E: Extended): Extended;
Returns the E, inversed.

function DecRet(E: Extended): Extended;
Returns the decimal part of E.
Example:
DecRet(28.4678) = 0.4678

function InCircle(x, y, mx, my, r: Integer): Boolean;
Returns true if x and y are in or on a circle specified by the midpoints mx, my and the radius r.

function InTriangle(x, y, x1, y1, x2, y2, x3, y3: Integer): Boolean;
Returns true if the coordinate x, y is in the truangle defined by the coordinates: (x1, y1) (x2, y2) (x3, y3).

function AdjustD(Angle, Adjustment: Extended): Extended;
Adds Adjustment to Angle and returns the angle in 0-360 form.

function FixR(Radians: Extended): Extended;
Returns Radians in 0 to 2Pi form.

function AdjustR(Angle, Adjustment: Extended): Extended;
Adds Adjustment to Angle and returns in 0 to 2Pi form.

function AMin(Data: TIntegerArray): Integer;
Returns the smallest integer value of all values in Data.

function AMinE(Data: TExtendedArray): Extended;
Returns the smallest extended value of all values in Data.

function AMax(Data: TIntegerArray): Integer;
Returns biggest integer value of all values in Data.

function AMaxE(Data: TExtendedArray): Extended;
Returns biggest extended value of all values in Data.

function iAbs(Number: Integer): Integer;
Returns absolute value of an integer (converts negative number to positive).

function ToCart(Point: PPoint): TPoint;
Returns the Cartesian Point of Polar Point point relative to the origin.

function ToCartOffset(Point: PPoint; offset: TPoint): TPoint;
Returns the Cartesian Point of Polar Point point, relative to the offset.
Note: The Polar Point is relative to offset, the Cartesian Point is Relative to the origin.

function ToPolar(Point: TPoint): PPoint;
Returns the Polar Point, relative to the origin, of Cartesian Point point.

function ToPolarOffset(Point, offset: TPoint): PPoint;
Returns the Polar Point, relative to the offset, of Cartesian Point point.
Note: The Polar Point is relative to the offset, the point and offset are Relative to the origin.
Note2: To turn the result back to cartesian use: ToCartOffset(result, offset).

function Average(Values: TExtendedArray): Extended;
Returns the average of the entered Values.

procedure BubbleSort(var Values: TIntegerArray);
Sorts the values in the entered array from small to large using the BubbleSort algorithm.

procedure BubbleSortB(var Values: TIntegerArray);
Sorts the values in the entered array from large to small using the BubbleSort algorithm.

function Average(Values: TExtendedArray): Extended;
Returns the average of the entered Values.


function Left(Text: string; Count: Integer): string;
Returns a part of the leftside of a string, the length is specified by Count.

function Right(Text: string; Count: Integer): string;
Returns a part of the rightside of a string, the length is specified by Count.

function TrimNumbers(Text: string): string;
Removes all numerical chars from a string.

function TrimLetters(Text: string): string;
Removes all alphabetical chars from a string.

function TrimOthers(Text: string): string;
Removes all chars that are not numerical and not alphabetical from a string.

function PosEx(search, s: string; from: Integer): Integer;
Returns the position of the substring in s searching forwards from from.

function LastPosEx(search, s: string; from: Integer): Integer;
Returns the position of the substring in s searching backwards from from.

function LastPos(search, s: string): Integer;
Returns the position of the substring in s searching backwards from the end of the string.

function StartsWith(prefix, s: string): Boolean;
Returns true if s starts with prefix.

function EndsWith(suffix, s: string): Boolean;
Returns true if s ends with suffix.

function TrimEx(delimiter, s: string): string;
Trims the specified delimiter from the start and end of the string.

function RegexPos(Txt, Regex: string): Integer;
Returns the position of the first found occurence of the regex.

function FindRegex(Txt, Regex: string): string;
Returns the string found by the regex.

function ReplaceRegex(Txt, Regex, ReplaceStr: string): string;
Replaces all occurences of the found regex by ReplaceStr.

function MD5(s: string): string;
Converts a string to an MD5 hash.

function ExplodeEx(Separator, s: string; Limit: Integer): TStringArray;
Explodes a string into pieces with a Limit.

function DecRet(E: Extended): Extended;
begin
Result := E - Trunc(E);
end;

function EndsWith(Suffix, S: string): Boolean;
begin
Result := Pos(Suffix, S) = (Length(S) - Length(Suffix) + 1);
end;

Wizzup?

2010-07-25 14:03:28

@Ice: No to be a pest, but what's so special about any of the following functions?

function AMaxE(Data: TExtendedArray): Extended;
Returns biggest extended value of all values in Data.

function iAbs(Number: Integer): Integer;
Returns absolute value of an integer (converts negative number to positive).

procedure BubbleSort(var Values: TIntegerArray);
Sorts the values in the entered array from small to large using the BubbleSort algorithm.

procedure BubbleSortB(var Values: TIntegerArray);
Sorts the values in the entered array from large to small using the BubbleSort algorithm.

function Average(Values: TExtendedArray): Extended;
Returns the average of the entered Values.

Bubblesort seems overkill since we already have QuickSort, which is a lot faster. The others… they don't do anything special do they?


Will add:

  • Tan
  • Radians
  • Degrees
  • DecRet
  • Some of the mentioned string functions, will post list later.
  • Carthesian/Polar point conversion (possibly!)
  • Other math functions. (Later)

E: Oh, and MessageBox.

Wanted

2010-07-25 14:17:09

I was hoping you would add more, I can see maybe BubbleSort is unneeded as with some others, but at least half if not 75% of those would be good to have. Especially a lot of the string functions.

Edit: I guess thats good enough, it would still be good to have a lot of the others though still I think.

Nava2

2010-07-25 18:19:15

I don't see why you would need a lot of those math functions. Most of them are derived from other math functions.

Tan is an exception because I'm sure there are some parts which are improved when using the sin() and cos() algorithm together.

Wizzup?

2010-07-25 18:46:27

From: Nava2
I don't see why you would need a lot of those math functions. Most of them are derived from other math functions.

Tan is an exception because I'm sure there are some parts which are improved when using the sin() and cos() algorithm together.


They are quite useful, as some are pretty hard to reproduce. But then again, if you can't reproduce them, why would you use them? Nah, they need to be in.

Wizzup?

2010-07-25 19:37:34

Doing some math wrappers now. (Not doing all, as I found some not to be in FPC atm, but they didn't seem important)

Anyway, writing wrappers made easy: http://wizzup.org/static/vim.ogg

Nava2

2010-07-26 00:02:47

From: Wizzup?
Doing some math wrappers now. (Not doing all, as I found some not to be in FPC atm, but they didn't seem important)

Anyway, writing wrappers made easy: http://wizzup.org/static/vim.ogg


that is so fucking cool.

Yeah, I swore. Its relevant.

SubiN

2010-07-26 00:40:57

how is trignometric functions useful in simba ? Give me something practical

Wanted

2010-07-26 01:50:28

From: SubiN
how is trignometric functions useful in simba ? Give me something practical


Splines, positioning, mapwalk especially. Considering these are already in Uses/Math and implementing is as simple as creating wrappers, why not? Also, think outside the box. GE Predictors, advanced algorithms, 3D objects, games. ect..

i luffs yeww

2010-07-26 02:05:01

Also remember that Simba can be used for things other than RuneScape. ;)

Wizzup?

2010-07-31 15:23:47

Commited most of the math functions plus PosEx. (They are in Unstable, see sig)

Any particular string functions that are required?

Daniel

2010-07-31 19:53:32

From: Wizzup?
Commited most of the math functions plus PosEx. (They are in Unstable, see sig)

Any particular string functions that are required?


ReverseString,
PosReverse,
PosReverseEx.

Meh, I can't think of anything :p

Nava2

2010-08-01 00:44:55

If we can get overloaded operators, an array with a negative sign should reverse it (same with string)

Wizzup?

2010-08-01 18:55:11

Math functions now in Stable (706)