void generateInitialTraj(MotionOptimizer & chomper, int N, const vec2f& p0, const vec2f& p1, MatX& q0, MatX& q1) { q0.resize(1, 2); q1.resize(1, 2); q0 << p0.x(), p0.y(); q1 << p1.x(), p1.y(); chomper.getTrajectory().initialize( q0, q1, N ); }
bool baryCentricTriangle(vec2f p, vec3f v1, vec3f v2, vec3f v3, float &u, float &v, float &r) { float x1mx3 = v1.x() - v3.x(); float x2mx3 = v2.x() - v3.x(); float y1my3 = v1.y() - v3.y(); float y2my3 = v2.y() - v3.y(); float det = (x1mx3 * y2my3) - (y1my3*x2mx3); float pxmx3 = p.x() - v3.x(); float pymy3 = p.y() - v3.y(); if(det == 0.0 || det == -0.0) return false; u = (y2my3*pxmx3 + x2mx3*-1*pymy3)/det; v = (y1my3*-1*pxmx3 + x1mx3*pymy3)/det; r = 1-u-v; if (u > 1.0f || v > 1.0f || r > 1.0f) return false; if (u < 0.0f || v < 0.0f || r < 0.0f) return false; return true; }
void Shader::setUniform(const std::string &name, const vec2f v, bool warn) { glUniform2f(uniform(name, warn), v.x(), v.y()); }
void Camera::setViewport(vec2f dim) { vpWidth = dim.x(); vpHeight = dim.y(); hasProjChanged = true; }