21 #define _USE_MATH_DEFINES 34 if (len < 0.0000000001) {
46 int max_extent =
MAX(abs(x), abs(y));
55 static int sign(
int x) {
64 if (fwrite(&xcoord,
sizeof(xcoord), 1, fp) != 1)
return false;
65 if (fwrite(&ycoord,
sizeof(ycoord), 1, fp) != 1)
return false;
71 if (fread(&xcoord,
sizeof(xcoord), 1, fp) != 1)
return false;
72 if (fread(&ycoord,
sizeof(ycoord), 1, fp) != 1)
return false;
87 int* major,
int* minor)
const {
88 int abs_x = abs(xcoord);
89 int abs_y = abs(ycoord);
92 major_step->
xcoord = sign(xcoord);
95 minor_step->
ycoord = sign(ycoord);
101 major_step->
ycoord = sign(ycoord);
102 minor_step->
xcoord = sign(xcoord);
117 xcoord = cos(radians);
118 ycoord = sin(radians);
130 return direction * M_PI / 128.0 - M_PI;
137 const FCOORD& dir_vector)
const {
138 FCOORD point_vector(*
this - line_point);
143 double lambda = point_vector % dir_vector / dir_vector.
sqlength();
144 return line_point + (dir_vector * lambda);
void setup_render(ICOORD *major_step, ICOORD *minor_step, int *major, int *minor) const
static uinT8 binary_angle_plus_pi(double angle)
bool normalise()
Convert to unit vec.
float angle() const
find angle
int direction(EDGEPT *point)
void from_direction(uinT8 direction)
int IntCastRounded(double x)
FCOORD nearest_pt_on_line(const FCOORD &line_point, const FCOORD &dir_vector) const
bool DeSerialize(bool swap, FILE *fp)
static double angle_from_direction(uinT8 direction)
float sqlength() const
find sq length
bool Serialize(FILE *fp) const
uinT8 to_direction() const
void set_with_shrink(int x, int y)
Set from the given x,y, shrinking the vector to fit if needed.
float length() const
find length
void ReverseN(void *ptr, int num_bytes)
ELISTIZE(ICOORDELT) bool FCOORD