35 template <
class numeric_type>
39 point(numeric_type
x = 0, numeric_type
y = 0);
44 void set(numeric_type
x, numeric_type
y);
47 numeric_type
x()
const {
return _x; }
48 numeric_type
y()
const {
return _y; }
50 numeric_type
r()
const;
101 template <
class numeric_type>
104 template <
class numeric_type>
108 template <
class numeric_type>
111 numeric_type temp = 0;
117 template <
class numeric_type>
121 template <
class numeric_type>
125 return numeric_type(sqrt(sumsquar));
128 template <
class numeric_type>
130 { set(numeric_type(r * theta.
cosine()), numeric_type(r * theta.
sine())); }
132 template <
class numeric_type>
136 return numeric_type(sqrt(sumsquar));
139 template <
class numeric_type>
146 template <
class contents>
155 template <
class contents>
162 template <
class contents>
170 template <
class numeric_type>
174 return numeric_type(sqrt(sumsquar));
177 template <
class numeric_type>
181 template <
class numeric_type>
185 template <
class numeric_type>
187 { _x += arg2.
x(); _y += arg2.
y();
return *
this; }
189 template <
class numeric_type>
191 { _x -= arg2.
x(); _y -= arg2.
y();
return *
this; }
193 template <
class numeric_type>
197 double epsilon = 1e-10;
202 template <
class numeric_type>
206 numeric_type tempX = x();
207 numeric_type tempY = y();
208 numeric_type temp1 = numeric_type(tempX * theta.
cosine()
209 - tempY * theta.
sine());
210 numeric_type temp2 = numeric_type(tempX * theta.
sine()
211 + tempY * theta.
cosine());
215 template <
class numeric_type>
218 numeric_type x = 0, y = 0;
int length() const
Returns the current reported length of the allocated C array.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
int convert(int default_value) const
Converts the string into a corresponding integer.
A very common template for a dynamic array of bytes.
Outcomes describe the state of completion for an operation.
A base class for objects that can pack into an array of bytes.
contents cosine() const
returns the cos function of this angle.
contents sine() const
returns the sin function of this angle.
static angle arctangent(double opposite, double adjacent, basis::outcome &retval)
returns the atan of the angle.
double_angle provides a non-templated class for forward declarations.
Represents a geometric point.
void set(numeric_type r, double_angle theta)
point(numeric_type r, double_angle theta)
bool operator==(const point &arg2) const
virtual bool unpack(basis::byte_array &packed_form)
Restores the packable from the "packed_form".
point operator-() const
return the additive inverse of the vector
void set(numeric_type x, numeric_type y)
point operator+(const point &arg2) const
basis::astring text_form() const
Prints out the two values (x and y) held in the point.
bool from_text(const basis::astring &text)
returns true if the "text" is successfully pulled into this point.
numeric_type distance(const point &p2) const
Returns the distance between ‘this’ and the second point ‘p2’.
point & operator+=(const point &arg2)
point(numeric_type x=0, numeric_type y=0)
virtual void pack(basis::byte_array &packed_form) const
Creates a packed form of the packable object in "packed_form".
int packed_size() const
Estimates the space needed for the packed structure.
numeric_type magnitude() const
return the distance from the origin to this point.
point & operator-=(const point &arg2)
DEFINE_CLASS_NAME("point")
double_angle theta() const
point rotate(const double_angle &theta) const
Rotates the point by the angle "theta".
Provides some fairly low-level math support.
type square(const type &a)
Returns the square of the object (which is a * a).
type absolute_value(type a)
Returns a if a is non-negative, and returns -a otherwise.
Contains all of our objects for geometry and avoids name clashes.
basis::astring numeric_specifier(numeric_type t)
Guesses the formatting string needed for the type provided.
astring crop_non_numeric(const astring &input)
Eats the non-numeric characters from the front of "input".
astring crop_numeric(const astring &input)
Eats the numeric characters from the front of "input".
void attach(byte_array &packed_form, const byte_array &to_attach)
Packs a byte_array "to_attach" into "packed_form".
void pack(basis::byte_array &packed_form, const set< contents > &to_pack)
provides a way to pack any set that stores packable objects.
bool detach(byte_array &packed_form, byte_array &to_detach)
Unpacks a byte_array "to_detach" from "packed_form".