Created
April 6, 2012 19:55
-
-
Save roxlu/2322523 to your computer and use it in GitHub Desktop.
Calculate coordinate system based on direction vector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Tubes::computeEdgeCoordinateSystems() { | |
Vec3 dir; | |
float inv = 0.0f; | |
vector<Edge*>::iterator it = graph.edges.begin(); | |
while(it != graph.edges.end()) { | |
Edge* e = (*it); | |
dir = graph.getEdgeDirection(e).normalize(); | |
e->z_axis = dir; | |
if(fabsf(dir.x) > fabsf(dir.y)) { | |
inv = 1.0f / sqrtf(dir.x*dir.x + dir.z*dir.z); | |
e->y_axis.set(-dir.z * inv, 0.0f, dir.x * inv); | |
} | |
else { | |
inv = 1.0f / sqrtf(dir.y*dir.y + dir.z*dir.z); | |
e->y_axis.set(0.0f, dir.z * inv, -dir.y * inv); | |
} | |
e->x_axis = cross(e->z_axis, e->y_axis); | |
++it; | |
} | |
} |
Author
roxlu
commented
Apr 6, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment