optional<Vector3> Plane::intersectLine( const Line3& line) { auto target = Vector3(); return intersectLine(line, target); }
void _SoNurbsPickV4CurveMap::point( float *v ) // //////////////////////////////////////////////////////////////////////// { // // Store the incoming point and the texture coordinate at that point // CP[ptIndex][0] = v[0]/v[3]; CP[ptIndex][1] = v[1]/v[3]; CP[ptIndex][2] = v[2]/v[3]; TP[ptIndex][0] = tmpTexPt[0]; TP[ptIndex][1] = tmpTexPt[1]; // // If the vertex has not completed a line yet, just increment // the point count and return. // if (ptIndex < 1) { ++ptIndex; return; } // Intersect the current line intersectLine(); // Overwrite the old vertex with the current vertex. CP[0][0] = CP[1][0]; CP[0][1] = CP[1][1]; CP[0][2] = CP[1][2]; TP[0][0] = TP[1][0]; TP[0][1] = TP[1][1]; }
Vector3 Plane::intersectLine(const Line& line) const { Vector3 intersection; confirm(intersectLine(line, &intersection)) else { Vector3 v; return v; } return intersection; }
void Particle::update(float dt, const Vec3f& accel, const std::vector<Segment>& segs) { // Reduce the time to live, and if dead or not updating positions automatically return _lifeLeft -= dt; if (!isAlive()) { return; } // Update the position _oldPosition = _position; _position += _velocity * dt; // Update the velocity _oldVelocity = _velocity; _velocity += accel * dt; Vec2f entPos(31, 3); /// @todo HACK FOR DEMO Vec2f oldPos(_oldPosition[0], _oldPosition[1]); Vec2f newPos(_position[0], _position[1]); Segment pline(oldPos + entPos, newPos + entPos); for (size_t i = 0; i < segs.size(); ++i) { const Segment& s = segs[i]; // need the normal of this segment. Vec2f n = perp(s.v2 - s.v1); if (dot(n, Vec2f(_oldVelocity[0], _oldVelocity[1])) > 0) { n = -n; } normalize(n); Vec2f p; float t = intersectLine(p, pline, s); if (t >= 0 && t <= 1) { Vec2f I = pline.v2 - pline.v1; Vec2f R = I - 2 * dot(n, I) * n; Vec2f p = pline.v1 + I * t + R * (1 - t); Vec2f v = normal(R) * length(_velocity) * 0.5f; p -= entPos; _position[0] = p[0]; _position[1] = p[1]; _velocity[0] = v[0]; _velocity[1] = v[1]; _oldPosition = _position; _oldVelocity = _velocity; break; } } }
bool PhysicalCircle::intersectLine(Line line, sf::Vector2f& intersectionPoint) const { sf::Vector2f dummy; return intersectLine(line, intersectionPoint, dummy); }
bool PhysicalCircle::intersectLine(Line line) const { sf::Vector2f dummy1; sf::Vector2f dummy2; return intersectLine(line, dummy1, dummy2); }
Vector3 Plane::pointOnPlane() const { // ax + by + cz + d = 0 Line line; line.set(Vector3::make(0,0,0), Vector3::make(a,b,c)); return intersectLine(line); }