Copyright 6 Vista 7 new! Languages 8 Glovepie scripts 9



Download 0.65 Mb.
Page3/30
Date conversion08.07.2018
Size0.65 Mb.
1   2   3   4   5   6   7   8   9   ...   30

Functions

Here are some of the functions that exist in GlovePIE


NEW! Pixel colour Functions
ScreenPixel(x, y): colour of screen pixel at (x, y) as an integer, in hexadecimal it looks like 0xRRGGBB. This is the opposite of the way the windows DLLs do it, but it is the way the internet and DirectX do it. To display it:
Debug = “0x”+ IntToHex(ScreenPixel(0, 0), 6)
You can also treat it like a vector:
[var.r, var.g, var.b] = ScreenPixel(0, 0)
debug = var.r+’, ‘+var.g+’, ‘+var.b
That will set var.r, var.g, and var.b to the values between 0 and 1 corresponding to the amount of red, green, and blue in the colour. The (0, 0) coordinates could be any pixel coordinates.
Trigonometry Functions
All angles are measured in degrees by default.

The following trigonometry functions are implemented:


Standard trig functions: sin, cos, tan, sec, cosec, cotan

Hyperbolic trig functions: SinH, CosH, TanH, SecH, CosecH, CotH


Inverse trig functions: aSin, aCos, aTan, aSec, aCosec, aCotan

Inverse Hyperbolic trig functions: aSinH, aCosH, aTanH, aSecH, aCosecH, aCotanH


2D inverse tan function: atan2
Rounding Functions
These functions preserve the units of their parameters.
ceil: Rounds towards infinity

floor: Rounds towards negative infinity

trunc, int: Rounds towards zero

round: Rounds towards nearest integer. .5 rounds to nearest even number (Bankers' Rounding)


frac: Returns signed fractional component. eg Frac(-1.32) = -0.32
RoundTo(x, digits): If digits is negative, rounds to that many decimal places using Banker's Rounding

If digits is positive, rounds to that power of ten using Banker's Rounding.


SimpleRoundTo(x [, digits]): Same as RoundTo except 0.5 always rounds up. Unfortunately -1.5 rounds up to 1.

digits defaults to -2 (meaning 2 decimal places).


Sign Functions
Sign: returns the sign of a number. 1 if it is positive, 0 if it is zero, -1 if it is negative

Abs: returns the modulus or absolute value. Removes the sign of a number. Preserves units.


Exponential and Square Root Functions
Raising things to the power of something:
sqr(x): caculates x^2

sqrt(x): calculates the square root of x. x^(1/2)

power(x,y): calculates x^y

intPower(x,y): calculates x^y where x and y are integers (the result is not an integer if y is negative)

exp(x): calculates e^x. e is 2.71828. The derivative of e^x is e^x.

Ldexp(s,p): calculates s * (2^p)


Poly(x, a0, [a1, [a2, [a3, [a4, [a5, [a6]]]]]]): returns a0 + a1*x + a2*(x^2) + a3*(x^3) + a4*(x^4) + ...

Logarithms (undoing raising something to some power):


Log10(x): returns the number you have to raise 10 to the power of, in order to get x. eg. Log10(1000) = 3

Log2(x): returns the number you have to raise 2 to the power of, in order to get x. eg. Log2(256) = 8

LogN(N, x): returns the number you have to raise N to the power of, in order to get x. eg. LogN(10, 1000) = 3

Ln(x): returns the number you have to raise e (2.71828) to the power of, in order to get x

LnXP1(x): the same as above, but for x+1 instead of x
Comparison functions
IsZero(x): returns true if x is zero

IsInfinite(x): returns true if x is infinite

IsNaN(x): returns true if x is not a number
SameValue(a, b [, epsilon]): returns true if a and b are the same, or differ by no more than epsilon

InSet(x,a,b,c,d,e,f,g,...): returns true if x matches one of the values following it.


max(a,b): returns the maximum of two values. Preserves units.

min(a,b): returns the minimum of two values. Preserves units.


Range functions
EnsureRange(x, a, b): Returns the closest value to x which is within the range [a, b]. Preserves units.

InRange(x, a, b): Returns true if x is within the range [a, b].


MapRange(x, a, b, c, d): Returns value x converted from the range [a, b] to the range [c, d]. Values outside the original range will map to the appropriate values outside the new range.
EnsureMapRange(x, a, b, c, d): The same as MapRange except values outside the range are mapped to the closest values inside the range.
NEW! DeadZone(x, a): Returns value x between -1 and 1, but with a deadzone around zero, so that values within the range [-a, a] of the zero point become 0, and other values between -1 and 1 are scaled to compensate. You should only use this function for values roughly between -1 and 1, like joystick values.
Random functions
Random: Returns a random fractional number between 0 and 1.

Random(n): Returns a random whole number between 0 and n-1.

RandomRange(a,b): Returns a random whole number between a and b.

RandG(mean, StandDev): Returns a random number from gaussian distribution around mean. Preserves units.


Ordinal functions
odd(n): Returns true if n is odd

pred(n): Returns n-1

succ(n): Returns n+1
Date/Time functions
NEW! TimeStamp or GetTimeStamp: A precise timestamp measured in seconds, from an arbitrary starting point. Much more accurate than the other time functions (which are measured in days).

Now: Current time and date (in days since December 30, 1899)

Time: Current time (in fractions of a day)

Date: Current date (in days since December 30, 1899)


Tomorrow: Tomorrow's date (in days since December 30, 1899)

Yesterday: Yesterday's date (in days since December 30, 1899)


CurrentYear: Current year of the Gregorian calendar (in years).
DateOf(x): Returns the date part of the date and time in x (in days since December 30, 1899)

TimeOf(x): Returns the time part of the date and time in x (in fractions of a day)

Dayofthemonth(x), dayoftheweek(x), dayoftheyear(x), dayofweek(x),

Daysbetween(x, y),

Daysinamonth(x, y), daysinayear(x), daysinmonth(x), daysinyear(x), DaySpan(x, y),

HourOfTheDay(x), HourOfTheMonth(x), HourOfTheWeek(x), HourOfTheYear(x),

HoursBetween(x, y), HourSpan(x, y),

IncDay(x, [y])



Temporal functions



NEW! Delta(x)
How much x has changed since the previous GlovePIE frame. It will be negative if x has decreased.
Smooth(x, [ExtraFrames, [DeadbandDistance]])
Smooths out the value of x by averaging with the previous ExtraFrames frames. If it hasn’t changed by more than DeadbandDistance it doesn’t count as changed at all. By default DeadbandDistance is 0.
NEW! Kalman(x, noise1, noise2)
Smooths using a Kalman filter, in theory. It has a tendency to diverge if you get the noise values wrong. Don’t ask me what the correct noise values are.
Pressed(x), Clicked(x), SingleClicked(x), DoubleClicked(x)
Returns true or false.
HeldDown(x, MinTime)
Returns true if x has been held down for at least MinTime.
KeepDown(x, MinTime)
Keeps the result being true after x has stopped being true, until MinTime is up.
1   2   3   4   5   6   7   8   9   ...   30


The database is protected by copyright ©dentisty.org 2016
send message

    Main page