|
Re: Calculating the angle of a point in relation to another February 13, 2012 12:49AM | Registered: 15 years ago Posts: 363 |
Quote
Titmouse
tueidj - I see, thanks for the info.
Sorry Owen, hitting your thread a bit hard now wth off subject matters ;)
|
Re: Calculating the angle of a point in relation to another February 13, 2012 05:14PM | Registered: 15 years ago Posts: 363 |
|
Re: Calculating the angle of a point in relation to another February 13, 2012 06:36PM | Registered: 14 years ago Posts: 99 |
|
Re: Calculating the angle of a point in relation to another February 13, 2012 07:11PM | Registered: 15 years ago Posts: 363 |
|
Re: Calculating the angle of a point in relation to another February 13, 2012 11:41PM | Registered: 14 years ago Posts: 99 |
|
Re: Calculating the angle of a point in relation to another March 04, 2012 02:04AM | Registered: 15 years ago Posts: 363 |
guVector rotate_vec_to_angle( guVector position_vec, guVector center_vec, float rot_deg_x, float rot_deg_y, float rot_deg_z ) {
guVector orig_direction = position_vec;
Mtx m,om;
guMtxIdentity(m);
guMtxApplyTrans (m, om, -center_vec.x, -center_vec.y, -center_vec.z);
guMtxRotDeg(m, 'x', rot_deg_x); // rotate around y axis
guMtxConcat(m, om, om);
guMtxRotDeg(m, 'y', rot_deg_y); // rotate around x axis
guMtxConcat(m, om, om);
guMtxRotDeg(m, 'z', rot_deg_z); // rotate around z axis
guMtxConcat(m, om, om);
guMtxIdentity(m);
guMtxApplyTrans (m, m, center_vec.x, center_vec.y, center_vec.z);
guMtxConcat(m, om, om);
guVecMultiply(om, &orig_direction, &position_vec);
return position_vec;
}|
Re: Calculating the angle of a point in relation to another March 10, 2012 10:15AM | Registered: 14 years ago Posts: 99 |
|
Re: Calculating the angle of a point in relation to another March 10, 2012 07:50PM | Registered: 15 years ago Posts: 363 |
|
Re: Calculating the angle of a point in relation to another March 11, 2012 10:35AM | Registered: 14 years ago Posts: 99 |
|
Re: Calculating the angle of a point in relation to another March 13, 2012 10:37PM | Registered: 15 years ago Posts: 363 |
|
Re: Calculating the angle of a point in relation to another March 15, 2012 04:32PM | Registered: 15 years ago Posts: 363 |
|
Re: Calculating the angle of a point in relation to another March 15, 2012 08:58PM | Registered: 14 years ago Posts: 99 |
|
Re: Calculating the angle of a point in relation to another March 15, 2012 10:00PM | Registered: 14 years ago Posts: 99 |
|
Re: Calculating the angle of a point in relation to another March 16, 2012 05:10AM | Registered: 15 years ago Posts: 363 |
|
Re: Calculating the angle of a point in relation to another March 17, 2012 05:18PM | Registered: 15 years ago Posts: 363 |
guVector rotate_vector_to_angle( guVector player_target, guVector player_position, float angx, float angy, float angz ){
static guVector _GRRaxisx = (guVector){1, 0, 0}; // DO NOT MODIFY!!!
static guVector _GRRaxisy = (guVector){0, 1, 0}; // Even at runtime
static guVector _GRRaxisz = (guVector){0, 0, 1}; // NOT ever!
Mtx g_ObjTransformationMtx; //hack ... moved into gloabal space
Mtx m, rx,ry,rz;
Mtx mv, mvi;
guMtxIdentity(g_ObjTransformationMtx);
//if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)) {
guMtxIdentity(m);
guMtxScaleApply(m, m, 1, 1, 1); //no need to scale. scale is always 1
guMtxConcat(m, g_ObjTransformationMtx, g_ObjTransformationMtx);
//}
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)) {
guMtxIdentity(m);
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
guMtxRotAxisDeg(rz, &_GRRaxisz, angz);
guMtxConcat(ry, rx, m);
guMtxConcat(m, rz, m);
guMtxConcat(m, g_ObjTransformationMtx, g_ObjTransformationMtx);
}
//if((player_position.x !=0.0f) || (player_position.y !=0.0f) || (player_position.y !=0.0f)) {
guMtxIdentity(m);
guMtxTransApply(m, m, player_position.x, player_position.y, player_position.z); //always done
guMtxConcat(m, g_ObjTransformationMtx, g_ObjTransformationMtx);
//}
guVector orig_direction = player_target;
guMtxApplyTrans (g_ObjTransformationMtx, g_ObjTransformationMtx, -player_position.x, -player_position.y, -player_position.z);
guVecMultiply(g_ObjTransformationMtx, &orig_direction, &player_target);
return player_target; //returns the new location of the target location
}
guVector tracker_get_degrees_to_face_target(guVector current, guVector target ) {
//it calculates the angle needed for the [model] to face the target from current_position
float dx=target.x-current.x;
float dy=target.y-current.y;
float dz=target.z-current.z;
float hyp = sqrt(dx*dx + dz*dz);
float rx= atan2(dy, hyp);
float ry= atan2(dx, dz);
rx= rx * 57.2957795;
ry= ry * 57.2957795;
return (guVector){rx, ry, 0}; //no z necessary
}
|
Re: Calculating the angle of a point in relation to another March 22, 2012 04:52PM | Registered: 15 years ago Posts: 363 |
|
Re: Calculating the angle of a point in relation to another June 10, 2012 09:09AM | Registered: 15 years ago Posts: 363 |