Skip to content

adds math helpers#24

Open
ninjanomnom wants to merge 3 commits into
GinjaNinja32:devfrom
ninjanomnom:math-helpers
Open

adds math helpers#24
ninjanomnom wants to merge 3 commits into
GinjaNinja32:devfrom
ninjanomnom:math-helpers

Conversation

@ninjanomnom
Copy link
Copy Markdown

image

Comment thread dm/util.dm Outdated
#define ceil(x) (-round(-(x)))
#define floor(x) round(x)
#define clamp(x, low, high) max((low),min((high),(x)))
#define PI 3.1415
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rounding down, are we?

Comment thread dm/util.dm Outdated
#define PI 3.1415
#define SPEED_OF_LIGHT 3e8 //not exact but hey!
#define SPEED_OF_LIGHT_SQ 9e+16
#define INFINITY 1e31 //closer then enough
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually define this as 1.#INF instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inf has some odd properties, people can use it directly if they want but most uses at least in ss13 code is just "very large number"

Comment thread dm/util.dm Outdated

#define ISEVEN(x) (x % 2 == 0)

#define ISODD(x) (!ISEVEN(x))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will say that 1.5 is odd.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it is odd. I just remembered I need to make this use actual modulo though for decimals to work

Comment thread dm/util.dm Outdated
#define ROOT(n, x) (x ** (1 / n))

// secant
#define SEC(x) (1 / cos(x))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be grouped with COT and CSC.

@ninjanomnom
Copy link
Copy Markdown
Author

once the sibling pr for this is merged on tg I'll update this to fix some oddities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants