private bool IsCounterClockwise(point2d point1, point2d point2, point2d point3) { double result = (point2.x - point1.x) * (point3.y - point1.y) - (point3.x - point1.x) * (point2.y - point1.y); return(result > 0); }
public edge2d(int i_edge_id, point2d i_start_pt, point2d i_end_pt) { // constructor 1 this._edge_id = i_edge_id; this._start_pt = i_start_pt; this._end_pt = i_end_pt; this._mid_pt = new point2d(-1, (i_start_pt.x + i_end_pt.x) * 0.5, (i_start_pt.y + i_end_pt.y) * 0.5); }
public bool vertex_exists(point2d other) { if (start_pt.Equals(other) == true || end_pt.Equals(other) == true) { return(true); } return(false); }
public face2d(int i_face_id, point2d i_p1, point2d i_p2, point2d i_p3) { this._face_id = i_face_id; this._p1 = i_p1; this._p2 = i_p2; this._p3 = i_p3; this._mid_pt = new point2d(-1, (i_p1.x + i_p2.x + i_p3.x) / 3, (i_p1.y + i_p2.y + i_p3.y) / 3); set_incircle(); }
public polygon2d(int i_poly_id, List <point2d> i_poly_pt) { this._poly_id = i_poly_id; // assign the id this._mid_pt = findCentroid(i_poly_pt); this._poly_pts = i_poly_pt.OrderBy(obj => Math.Atan2(obj.x - this.mid_pt.x, obj.y - this.mid_pt.y)).ToList(); foreach (point2d pt in this._poly_pts) { get_poly_pts.Add(new PointF(Form1.the_static_class.to_single(_mid_pt.get_point().X *(1 - shrink_factor) + (pt.get_point().X *shrink_factor)), Form1.the_static_class.to_single(_mid_pt.get_point().Y *(1 - shrink_factor) + (pt.get_point().Y *shrink_factor)))); } }
public face2d(int i_face_id, point2d i_p1, point2d i_p2, point2d i_p3, point2d i_cpt, double i_radius) { this._face_id = i_face_id; this._p1 = i_p1; this._p2 = i_p2; this._p3 = i_p3; this._mid_pt = new point2d(-1, (i_p1.x + i_p2.x + i_p3.x) / 3, (i_p1.y + i_p2.y + i_p3.y) / 3); // set circle this._circle_center = new point2d(-1, i_cpt.x, i_cpt.y); this._circle_radius = i_radius; this._ellipse_edge = new point2d(-1, i_cpt.x - this._circle_radius, i_cpt.y + this._circle_radius); }
public triangle2d(int i_face_id, point2d i_p1, point2d i_p2, point2d i_p3) { this._face_id = i_face_id; if (!IsCounterClockwise(i_p1, i_p2, i_p3)) { this.vertices[0] = i_p1; this.vertices[1] = i_p3; this.vertices[2] = i_p2; } else { this.vertices[0] = i_p1; this.vertices[1] = i_p2; this.vertices[2] = i_p3; } this._mid_pt = new point2d(-1, (i_p1.x + i_p2.x + i_p3.x) / 3.0f, (i_p1.y + i_p2.y + i_p3.y) / 3.0f); }
private void set_incircle() { double dA = (this._p1.x * this._p1.x) + (this._p1.y * this._p1.y); double dB = (this._p2.x * this._p2.x) + (this._p2.y * this._p2.y); double dC = (this._p3.x * this._p3.x) + (this._p3.y * this._p3.y); double aux1 = (dA * (this._p3.y - this._p2.y) + dB * (this._p1.y - this._p3.y) + dC * (this._p2.y - this._p1.y)); double aux2 = -(dA * (this._p3.x - this._p2.x) + dB * (this._p1.x - this._p3.x) + dC * (this._p2.x - this._p1.x)); double div = (2 * (this._p1.x * (this._p3.y - this._p2.y) + this._p2.x * (this._p1.y - this._p3.y) + this._p3.x * (this._p2.y - this._p1.y))); if (div != 0) { } //Circumcircle double center_x = aux1 / div; double center_y = aux2 / div; this._circle_center = new point2d(-1, center_x, center_y); this._circle_radius = Math.Sqrt((center_x - this._p1.x) * (center_x - this._p1.x) + (center_y - this._p1.y) * (center_y - this._p1.y)); this._ellipse_edge = new point2d(-1, center_x - this._circle_radius, center_y + this._circle_radius); }
public bool Equals(point2d other) { return(this._x == other.x && this._y == other.y); // Equal function is used to check the uniqueness of the points added }
public bool is_close_enough(point2d other) { double eps = 0.001; return(Math.Abs(this._x - other.x) < eps && Math.Abs(this._y - other.y) < eps); }
void writePoint(point2d p) { fwriter.WriteStartObject(); writeValuef("lat", mRound(p.x)); writeValuef("lon", mRound(p.y)); fwriter.WriteEndObject(); }
bool PointEquals(point2d p1, point2d p2) { return (mRound(p1.x) == mRound(p2.x)) && (mRound(p1.y) == mRound(p2.y)); }
string node(point2d p, string id) { string key = vcTag + id; fwriter.WritePropertyName(key); fwriter.WriteStartArray(); writePoint(p); fwriter.WriteEndArray(); return key; }
bool move_node(point2d p1, point2d p2, string key) { if (!PointEquals(p1, p2)) { fwriter.WritePropertyName(vcTag + key); fwriter.WriteStartArray(); writePoint(p1); writePoint(p2); fwriter.WriteEndArray(); return true; } return false; }