10 #ifndef PIXPOINT_H_UOFARIZONAVISION
11 #define PIXPOINT_H_UOFARIZONAVISION 1
65 Unused(
const std::string&
m,
const char* f,
int l )
133 || (
y == pp.
y &&
x < pp.
x );
140 return x == pp.
x &&
y == pp.
y;
153 return operator=(
operator+( pp ) );
188 return x * pp.
x +
y * pp.
y;
210 float dx =
x-pp.x, dy =
y-pp.y;
211 return dx*dx + dy*dy;
230 return sqrt(
dist2(pp) );
275 std::string
str(
const std::string& sep =
", " )
const
278 return std::string(
"UNUSED" );
280 std::ostringstream
ss;
330 return x * pp.
y - pp.
x *
y;
410 static_cast<PixPoint::Integer>(
std::floor(v.
y() + 0.5)));
427 return PixPoint(static_cast<PixPoint::Integer>(std::ceil(v.
x())),
435 PixPoint
str_to_PixPoint( std::istream& iss,
const std::string& sep=
"," );
441 std::istringstream iss( spp );
static void fault_if(bool b)
throw exception if we try to operate on an unused point
Definition: pixpoint.h:71
Int_matrix::Value_type max(const Int_matrix &mat)
Return the maximum value in this matrix.
Definition: l_int_matrix.h:1397
PixPoint reckless_round(const kjb::Vector2 &v)
round to near integers, disregarding overrange values
Definition: pixpoint.h:405
bool operator!=(const Is_inbounds &that_functor) const
test whether this functor differs from another
Definition: pixpoint.h:388
PixPoint operator-(const PixPoint &pp) const
subtract two PixPoints when they are interpreted as 2-vectors
Definition: pixpoint.h:164
PixPoint operator+(const PixPoint &pp) const
add two PixPoints when they are interpreted as 2-vectors
Definition: pixpoint.h:157
float dist(const PixPoint &pp=PixPoint(0, 0)) const
Return distance between points, using the L2 norm.
Definition: pixpoint.h:227
PixPoint operator*(int factor) const
multiply components of a PixPoint by a factor (like 2-vector)
Definition: pixpoint.h:171
PixPoint reckless_ceil(const kjb::Vector2 &v)
round the vector contents to integers, disregarding overrange values
Definition: pixpoint.h:423
double y() const
Definition: m_vector_d.impl.h:169
float dist2(const PixPoint &pp=PixPoint(0, 0)) const
Distance squared between PixPoint objects, or from the origin.
Definition: pixpoint.h:207
Is_inbounds(PixPoint min_min, PixPoint width_height)
Establish the boundaries of the box: LL corner and size.
Definition: pixpoint.h:375
bool is_collinear(const PixPoint &p1, const PixPoint &p2) const
return true iff this point lies on the same line as line(p1,p2).
Definition: pixpoint.h:335
Object thrown when a function cannot generate a valid result.
Definition: l_exception.h:516
kjb::Vector2 to_vector2(const PixPoint &p)
convert the PixPoint to a floating point format
Definition: pixpoint.h:397
Integer cross(const PixPoint &pp) const
return cross product of two PixPoints interpreted as 2-vectors.
Definition: pixpoint.h:327
double x() const
Definition: m_vector_d.impl.h:134
bool is_poz_poz() const
Test whether a PixPoint has strictly positive x and y coords.
Definition: pixpoint.h:307
Integer idot(const PixPoint &pp) const
interp as 2-vec, compute dot prod as integer (beware overflow)
Definition: pixpoint.h:185
function straight edges straight lines(nlines,[x1 x2 y1 y2 theta r])%%To display result ss
Definition: APPgetLargeConnectedEdges.m:20
std::string str(const std::string &sep=", ") const
Express a PixPoint as a string (ascii coordinate values)
Definition: pixpoint.h:275
exception thrown if the PixPoint is used while uninitialized
Definition: pixpoint.h:63
PixPoint()
ctor sets fields to sentinel values to indicated "unused."
Definition: pixpoint.h:83
const bool TEST_PIXPOINT_UNUSED
extra test for unused PixPoint
Definition: pixpoint.h:34
void swap(PixPoint &that)
swap state of two pixpoints
Definition: pixpoint.h:95
Int_matrix floor(const Matrix &m)
Definition: m_matrix.cpp:2026
PixPoint operator/(int divisor) const
integer-divide components of a PixPoint (like a 2-vector)
Definition: pixpoint.h:178
bool operator!=(const PixPoint &pp) const
test whether two points differ (different integer coords)
Definition: pixpoint.h:144
bool operator==(const PixPoint &pp) const
test whether two points are equivalent (same integer coords)
Definition: pixpoint.h:137
bool adjacent8(const PixPoint &pp) const
test adjacency using eight-connectivity (or identity).
Definition: pixpoint.h:268
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
Integer L_infinity_distance(const PixPoint &pp) const
Definition: pixpoint.h:251
Integer x
x coordinate of the pixel
Definition: pixpoint.h:79
PixPoint & operator+=(const PixPoint &pp)
add a PixPoint to this PixPoint, when interpreted as 2-vectors
Definition: pixpoint.h:150
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
Unused(const std::string &m, const char *f, int l)
Definition: pixpoint.h:65
PixPoint str_to_PixPoint(std::istream &iss, const std::string &sep)
scan a string value into a PixPoint
Definition: pixpath.cpp:1607
bool in_quadrant_I() const
Test whether a PixPoint has nonnegative x and y coordinates.
Definition: pixpoint.h:295
bool operator()(PixPoint querypoint) const
Predicate test: is it inside the established boundaries?
Definition: pixpoint.h:381
const PixPoint m_width_height
dimensions of bounding box
Definition: pixpoint.h:354
bool operator<(const PixPoint &pp) const
This operator imposes a total order on PixPoints.
Definition: pixpoint.h:129
Representation of an (x,y) pair of pixel coordinates.
Definition: pixpoint.h:57
PixPoint reckless_floor(const kjb::Vector2 &v)
truncate towards negative infinity, disregarding overrange values
Definition: pixpoint.h:414
for m
Definition: APPgetLargeConnectedEdges.m:64
Support for error handling exception classes in libKJB.
bool is_not_unused() const
convenience inline for better readability
Definition: pixpoint.h:109
bool is_used() const
another convenience inline that is not so unpositive.
Definition: pixpoint.h:115
Vector_d< 2 > Vector2
Definition: gr_opengl.h:35
const PixPoint m_min_min
minimum in-bounds x and y coordinates
Definition: pixpoint.h:354
bool is_unused() const
Test whether a PixPoint is unused (untouched since default ctor)
Definition: pixpoint.h:102
Integer y
y coordinate of the pixel
Definition: pixpoint.h:79
Predicate functor tests whether a PixPoint is in a bounding box.
Definition: pixpoint.h:351
PixPoint(Integer xx, Integer yy)
Basic ctor builds from two coordinates.
Definition: pixpoint.h:89
int Integer
any signed integer valued type is fine
Definition: pixpoint.h:60