19#define _USE_MATH_DEFINES
35 if (len < 0.0000000001) {
55 int max_extent = std::max(abs(
x), abs(
y));
56 if (max_extent > INT16_MAX) {
57 factor = max_extent / INT16_MAX + 1;
65static int sign(
int x) {
102 if (abs_x >= abs_y) {
129 xcoord = cos(radians);
130 ycoord = sin(radians);
142 return direction * M_PI / 128.0 - M_PI;
149 FCOORD point_vector(*
this - line_point);
154 double lambda = point_vector % dir_vector / dir_vector.
sqlength();
155 return line_point + (dir_vector * lambda);
void ReverseN(void *ptr, int num_bytes)
int IntCastRounded(double x)
bool DeSerialize(bool swap, FILE *fp, std::vector< T > &data)
bool Serialize(FILE *fp, const std::vector< T > &data)
void set_with_shrink(int x, int y)
Set from the given x,y, shrinking the vector to fit if needed.
TDimension y() const
access_function
bool DeSerialize(TFile *f)
TDimension x() const
access function
bool Serialize(TFile *f) const
void setup_render(ICOORD *major_step, ICOORD *minor_step, int *major, int *minor) const
void from_direction(uint8_t direction)
float length() const
find length
FCOORD nearest_pt_on_line(const FCOORD &line_point, const FCOORD &dir_vector) const
float angle() const
find angle
float sqlength() const
find sq length
bool normalise()
Convert to unit vec.
static double angle_from_direction(uint8_t direction)
uint8_t to_direction() const
static uint8_t binary_angle_plus_pi(double angle)
bool DeSerialize(std::string &data)
bool Serialize(const std::string &data)