2016-07-23 20:59:37 +03:00
|
|
|
/*
|
|
|
|
* misc.h - Helper functions for geometry and attributes
|
|
|
|
*
|
|
|
|
* Written 2016 by Werner Almesberger
|
|
|
|
* Copyright 2016 Werner Almesberger
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MISC_H
|
|
|
|
#define MISC_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
2016-07-31 07:51:04 +03:00
|
|
|
static inline int mxr(int x, int y, const int m[6])
|
2016-07-25 05:26:54 +03:00
|
|
|
{
|
|
|
|
return x * m[1] + y * m[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-31 07:51:04 +03:00
|
|
|
static inline int myr(int x, int y, const int m[6])
|
2016-07-25 05:26:54 +03:00
|
|
|
{
|
|
|
|
return x * m[4] + y * m[5];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-31 07:51:04 +03:00
|
|
|
static inline int mx(int x, int y, const int m[6])
|
2016-07-23 20:59:37 +03:00
|
|
|
{
|
2016-07-25 05:26:54 +03:00
|
|
|
return m[0] + mxr(x, y, m);
|
2016-07-23 20:59:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-31 07:51:04 +03:00
|
|
|
static inline int my(int x, int y, const int m[6])
|
2016-07-23 20:59:37 +03:00
|
|
|
{
|
2016-07-25 05:26:54 +03:00
|
|
|
return m[3] + myr(x, y, m);
|
2016-07-23 20:59:37 +03:00
|
|
|
}
|
|
|
|
|
2016-07-25 05:26:54 +03:00
|
|
|
|
2016-07-31 07:51:04 +03:00
|
|
|
unsigned matrix_to_angle(const int m[6]);
|
|
|
|
bool matrix_is_mirrored(const int m[6]);
|
2016-07-25 06:16:09 +03:00
|
|
|
int angle_add(int a, int b);
|
2016-07-23 20:59:37 +03:00
|
|
|
|
2016-07-30 04:13:07 +03:00
|
|
|
int rx(int x, int y, int rot);
|
|
|
|
int ry(int x, int y, int rot);
|
|
|
|
|
2016-07-23 20:59:37 +03:00
|
|
|
#endif /* !MISC_H */
|