Example #1
0
/** Function for calculating the center of a triangle defined by vertices v1, v2 and v3.
*/
void Triangle_Center(Coordinates& v, const Coordinates& v1, const Coordinates& v2, const Coordinates& v3)
{
    double r;

    // setting the initial coordinates for the vertice as a sum of coresponding components
    v.setCoordinates(v1.x+v2.x+v3.x, v1.y+v2.y+v3.y, v1.z+v2.z+v3.z);
    // ...and normalizing it to the sphere
    r = 1 / (sqrt(pow(v.x, 2) + pow(v.y, 2) + pow(v.z, 2)));
    v.x *= r;
    v.y *= r;
    v.z *= r;
}
Example #2
0
/** Function for calculating the middle point of an edge defined by vertices v1 and v2.
*/
void Edge_Subdivision(const Coordinates& v1, const Coordinates& v2, Coordinates& v3)
{
    double r;

    // setting the initial coordinates for the vertice as a sum of coresponding components
    v3.setCoordinates(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
    // ...and normalizing it to the sphere
    r = 1 / (sqrt(pow(v3.x, 2) + pow(v3.y, 2) + pow(v3.z, 2)));
    v3.x *= r;
    v3.y *= r;
    v3.z *= r;
}