19 #define _USE_MATH_DEFINES // for M_PI 30 float len = length ();
32 if (len < 0.0000000001) {
44 int max_extent = std::max(abs(x), abs(y));
45 if (max_extent > INT16_MAX)
46 factor = max_extent / INT16_MAX + 1;
53 static int sign(
int x) {
84 int* major,
int* minor)
const {
109 return binary_angle_plus_pi(
angle());
113 double radians = angle_from_direction(direction);
127 return direction * M_PI / 128.0 - M_PI;
134 const FCOORD& dir_vector)
const {
135 FCOORD point_vector(*
this - line_point);
140 double lambda = point_vector % dir_vector / dir_vector.
sqlength();
141 return line_point + (dir_vector * lambda);
int IntCastRounded(double x)
float angle() const
find angle
void from_direction(uint8_t direction)
void set_with_shrink(int x, int y)
Set from the given x,y, shrinking the vector to fit if needed.
bool DeSerialize(bool swap, FILE *fp)
void setup_render(ICOORD *major_step, ICOORD *minor_step, int *major, int *minor) const
float sqlength() const
find sq length
bool Serialize(FILE *fp, const char *data, size_t n)
static double angle_from_direction(uint8_t direction)
bool Serialize(FILE *fp) const
int16_t x() const
access function
int direction(EDGEPT *point)
FCOORD nearest_pt_on_line(const FCOORD &line_point, const FCOORD &dir_vector) const
ELISTIZE(ICOORDELT) bool FCOORD
uint8_t to_direction() const
bool DeSerialize(FILE *fp, char *data, size_t n)
void ReverseN(void *ptr, int num_bytes)
static uint8_t binary_angle_plus_pi(double angle)