Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
RangeSearch/kdtest/Point.pde
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49 lines (40 sloc)
1.1 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Point { | |
float _r = i_pointRad; | |
float _x; | |
float _y; | |
boolean _isSelected; | |
Point(float x0, float y0) { | |
_x = x0; | |
_y = y0; | |
_isSelected = false; | |
} | |
void draw() { | |
pushStyle(); | |
stroke(c_pointStroke); | |
fill((_isSelected) ? c_pointSelect : c_pointDefault); | |
ellipse(_x, _y, i_pointRad, i_pointRad); | |
popStyle(); | |
} | |
boolean isSelectedPoint(float x, float y) { | |
return (x - _x)*(x - _x) + (y - _y) * (y - _y) < _r * _r; | |
} | |
boolean isSelectedCir(float x, float y, float r) { | |
return (x - _x)*(x - _x) + (y - _y)*(y - _y) < r * r; | |
} | |
boolean isSelectedRect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { | |
int l0 = lineSideTest(x1, y1, x2, y2, _x, _y); | |
int l1 = lineSideTest(x2, y2, x3, y3, _x, _y); | |
int l2 = lineSideTest(x3, y3, x4, y4, _x, _y); | |
int l3 = lineSideTest(x4, y4, x1, y1, _x, _y); | |
return (l0 == l1) && (l1 == l2) && (l2 == l3); | |
} | |
void setSelected() { | |
_isSelected = true; | |
} | |
void setUnSelected() { | |
_isSelected = false; | |
} | |
void toggleSelected() { | |
_isSelected = !_isSelected; | |
} | |
} |