Пример #1
0
 Vect2 AziEquiProjection::project2(const LatLonAlt& lla) const {
   Vect2 p =  sphere_to_plane(ref, spherical2xyz(lla.lat(),lla.lon()));
   if (p.norm() <= 0.0) {
 	  return Vect2::ZERO;
   } else {
       return p.Scal(GreatCircle::distance(lla, llaRef)/p.norm());
   }
 }
Пример #2
0
Vect2 Vect2::intersect_pt(const Vect2& s0, const Vect2& v0, const Vect2& s1, const Vect2& v1) {
	if (Util::almost_equals(v0.det(v1),0.0)) {
		//fpln(" $$$$$$$$ ERROR $$$$$$$$$");
		return Vect2::INVALID();
	} else {
		Vect2 delta = s1.Sub(s0);
		double ss = delta.det(v1)/v0.det(v1);
		return s0.Add(v0.Scal(ss));
	}
}
Пример #3
0
Vect2 VectFuns::closestPoint(const Vect2& a, const Vect2& b, const Vect2& so) {
	// translate a to origin, then project so onto the line defined by ab, then translate back to a
	Vect2 ab = b.Sub(a);
	return ab.Scal(so.Sub(a).dot(ab)/ab.dot(ab)).Add(a);
//	if (collinear(a,b,so)) return so;
//	Vect2 v = a.Sub(b).PerpL().Hat(); // perpendicular vector to line
//	Vect2 s2 = so.AddScal(100, v);
//	Vect2 cp = intersection(so,s2,100,a,b).first;
//	return cp;
}
Пример #4
0
std::pair<Vect2,double> VectFuns::intersection(const Vect2& so, const Vect2& vo, const Vect2& si, const Vect2& vi) {
	Vect2 ds = si.Sub(so);
	if (vo.det(vi) == 0) {
		//f.pln(" $$$ intersection: lines are parallel");
		return std::pair<Vect2,double>(Vect2::ZERO(),  NaN);
	}
	double tt = ds.det(vi)/vo.det(vi);
	Vect2 intersec = so.Add(vo.Scal(tt));
	return std::pair<Vect2,double>(intersec,tt);
}
Пример #5
0
/**
 * returns the perpendicular distance between line defined vy s,v and point q.
 * @param s
 * @param v
 * @param q
 */
double Vect2::distAlong(const Vect2& s, const Vect2& v, const Vect2& q) {
	double tp = q.Sub(s).dot(v)/v.sqv();
	//f.pln(" $$$ distAlong: tp = "+tp);
	return Util::sign(tp)*v.Scal(tp).norm();

}
Пример #6
0
/**
 * returns the perpendicular distance between line defined vy s,v and point q.
 * @param s
 * @param v
 * @param q
 */
double Vect2::distPerp(const Vect2& s, const Vect2& v, const Vect2& q) {
	double tp = q.Sub(s).dot(v)/v.sqv();
	return s.Add(v.Scal(tp)).Sub(q).norm();

}
Пример #7
0
// This appears to use the right-hand rule to determine it returns the inside or outside angle
double VectFuns::angle_between(const Vect2& v1, const Vect2& v2) {
	Vect2 VV1 = v1.Scal(1.0/v1.norm());
	Vect2 VV2 = v2.Scal(1.0/v2.norm());
	return Util::atan2_safe(VV2.y,VV2.x)-Util::atan2_safe(VV1.y,VV1.x);
}