/Stencyl-Extended-Math

An extension for the game engine Stencyl that adds extra math functions to make math calculations easier.

Primary LanguageHaxeMIT LicenseMIT

Stencyl Extended Math

An extension for the game engine Stencyl that adds extra math functions to make math calculations easier.

Stencyl lacks a number of mathematical blocks that would have to be built from scratch for each game that uses functions like averages in a list, factorials, and logarithms of base n. This extension allows you to do these plus much more without building the math functions from scratch.

Math Header

----- Constants -----

NaN

NaN

Returns a constant NaN which denotes not a number.

Infinity

Infinity

Returns a constant which denotes the value of infinity.

Root 2

Root Two

Returns the value of the square root of 2.

Phi

Phi

Returns Phi (the golden ratio) which is equal to (1 + √5)/2 ≈ 1.618

Maximum Bit Integers

Max Bit Integer

Returns the maximum value of an 8, 16, 32, and 64 bit number.

----- Lists -----

Average, Max, Min values in List

List Calculations

Returns a specific number of the value of items in a given list which matches a desired characteristic.
Choices:

  • Average
  • Max
  • Min

Intersection, Union and Subtraction of Lists

List Intersection

Returns a list with a desired modification given 2 lists.
Choises:

  • Intersection: Returns a list of items found in both lists.
  • Union: Returns a unique set of items found in all lists.
  • Subraction: Returns the first list with all values from the second list removed in the first.

Subset

Subset

Returns true if every item is list A is also found in list B.

Summation

Summation

Returns the sum of all values in a given list.

Identity Matrix

Identity Matrix

Returns a matrix square of a given size with 1's along the diagonal

----- Math -----

Is Number

Is Number

Returns true if a given value is a number.

Is Even/Odd

Even Odd

Returns whether or not a number is even or odd.

+/-

Plus Minus

Returns a list of size 2 where the value of A + B is at index 0 and A - B is at index 1.

Inverse

Inverse

Returns the inverse 1/N of a number.

Divides

Divides

Returns true if the first number evenly divides the second.

Modular Arithmatic

Modular Arithmatic

Returns true if the remainder of each of the first two numbers divided by the last are the same.

Cube Root

Cube Root

Returns the cube root of a number.

N-th Root

Nth Root

Returns the N-th root of a number

Log with Base

Log Base

Returns the logarithm of a number with any base.

Factorial

Factorial

Returns the factorial of a number. ie. (N)(N-1)(N-2)...(1)

Pick

Pick

Returns the factorial of a number to a given step. ie. (N)(N-1)(N-2)...(N-(k-1))

Choose

Choose

Returns ((N)!/(N-k)!)/(k)!

sinh, cosh, tanh

Sinh, Cosh, Tanh

Returns sinh, cosh, or tanh.
~ sinh = (1/2) (-(1/e^N) + e^N)
~ cosh = (1/2) ((1/e^N) + e^N)
~ tanh = sinh(N)/cosh(N)

Implies

Implies

Returns false if the premise is true, but the outcome is false otherwise returns true.

Heaven Side Step

Heaven Side Step

Returns 0 if the number given is 0, 1 if the number given is larger than 0, and -1 if the number given is less than 0.

----- Positional Space -----

Distance Between Actors

Distance Between Actors

Returns the distance between 2 actors in the scene.

----- Geometry -----

Circle

Circle

Returns the area or circumerence of a circle with radius R.

Rectangle

Rectangle

Returns the area or parimeter of a rectangle with length L and width W.

Last Updated April 7, 2020 v1.0

Additional Notes: If you require additional math functions that are not included please let me know so I can add them

Contact Me: thejoblesscoder@gmail.com

Extension is Open Sourced and Licensed under MIT open source standards.