Example #1
0
inline std::tuple<vector,vector,vector> orthonormal_basis(const vector& v)
{
    vector v1 = v.normalize();

    auto v2_and_v3 = basis(v1);

    return std::make_tuple(v1, std::get<0>(v2_and_v3), std::get<1>(v2_and_v3));
}
Example #2
0
triangle::triangle(
    const point &p1,
    const point &p2,
    const point &p3,
    const vector &normal)
{
    this->vertices_ = std::vector<point>(3);
    this->vertices_[0] = p1;
    this->vertices_[1] = p2;
    this->vertices_[2] = p3;
    this->normal_ = normal.normalize();
    this->plan_offset_ = -(vector(p1)*this->normal_);
    this->set_basis(p1, p2, p3);
}