virtual void SetUp() { for (int i = 0; i < 7; ++i) { Point p; p.Init(i*53 % 13, i * 3.14, i / 1.123); p.id_ = i; points06.push_back(p); } for (int i = 7; i < 14; ++i) { Point p; p.Init(i*53 % 13, i * 3.14, i / 1.123); p.id_ = i; points713.push_back(p); } for (int i = 3; i < 10; ++i) { Point p; p.Init(i+1, i+2, i+3); p.id_ = i; saddle.push_back(p); } too_many = points06; Point p; p.Init(1, 2, 3); p.id_ = 7; too_many.push_back(p); }
virtual void SetUp() { ZeroMag_.Init(0, 0, 0); NearZeroMag_.Init(0.000000000000000000001, 0.000000000000000000001, 0.000000000000000000001); for (int i = 19; i >= 0; --i) { Point p; p.Init(i*173, i/79, i*1.735); p.id_ = i; points.push_back(p); } }
void TryShoot(double t) { Point c; c.Init(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z)); int i; for (i = 0; i < n && !HitBuilding(s, c, B[i]); ++i); if (i == n && resT > t) resT = t; }
// Normalize finds the unit vector // return the unit vector Point Point::Normalize() { Point p; float mag = Magnitude(); if (mag == 0) { p.Init(); return p; } p.x_ = x_ / mag; p.y_ = y_ / mag; p.z_ = z_ / mag; return p; }
void HitPlane(const Point & p, const Point & q, const Point & r, const Point & a, const Point & b) { double t; if (Intersect(p, q, r, a, b, t)) { Point c; c.Init(a.x+t*(b.x-a.x), a.y+t*(b.y-a.y), a.z+t*(b.z-a.z)); if (Inside(c, p, r) != 0) { mint = min(mint, t); maxt = max(maxt, t); } } }
// Init initializes the PSObject with the given information // identification : the id of the object // called : the name of the object // points : a vector of Points that define the PhaseSpace Object // t : the type_ of object bool PSObject::Init(int ident, string call, vector<Point> points, string t, bool rigid) { Point p; p.Init(); center_ = p; angle_.push_back(1); angle_.push_back(0); angle_.push_back(0); angle_.push_back(0); Point x_axis; x_axis.Init(1, 0, 0); Point y_axis; y_axis.Init(0, 1, 0); Point z_axis; z_axis.Init(0, 0, 1); axes_.push_back(x_axis); axes_.push_back(y_axis); axes_.push_back(z_axis); dim_.push_back(.1); dim_.push_back(.1); dim_.push_back(.1); name_ = call; id_ = ident; bool success; if (t == "glove") { GloveType* g = new GloveType; success = g->Init(points, rigid); type_ = static_cast<ObjectType*>(g); ext_ = "glove"; } else { DefaultType* d = new DefaultType; success = d->Init(points, rigid); type_ = static_cast<ObjectType*>(d); ext_ = "default"; } UpdateFields(); return success; }