- Joined
- Jun 6, 2012
- Messages
- 283
- Reaction score
- 65
- Points
- 28
- Location
- Sydney, Australia, Earth, Sol
- Website
- www.orbithangar.com
Hi All,
I would appreciate help with something rather complicated which I just can't seem to be able to approach on my own.
I want to return the 'angle' to the sun of a direction vector in local-vessel frame. To better explain I have posted below code which achieves something simillar.
The above is tailored for another purpose; to take the vessel's AOA and slip angle to the sun, and return a number between 0-1, with 0 being pointed directly at the sun and 1 being pointed directly away. I keep trying to work with this as a starting-point but have found myself going round in circles. I don't think this is the right approach but I have reached an impass!
What I would like, is to be able to have a direction vector in local frame (for example 0,1,0: pointed straight up) and return the same 0-1 value based on this vector's angle to the sun. I need for the vector to be able to be dynamic, say for if I wanted it to rotate around the vessel, say starting as (0,1,0) and ending as (0,0,-1). Essentially this is for solar panel simulation, but I would like for the solar panel's direction to be able to be any direction (in case of solar tracking). I know this is probabloy a very roundabout way of tackling this, but I am developing this as part of an SDK, which is why I have need for such a universal-approach.
Thank you anyone who can help me with this, any help is greatly appreciated!
MrMartian
I would appreciate help with something rather complicated which I just can't seem to be able to approach on my own.
I want to return the 'angle' to the sun of a direction vector in local-vessel frame. To better explain I have posted below code which achieves something simillar.
C++:
VECTOR3 toSun, solpos, gpos;
oapiGetGlobalPos(oapiGetGbodyByIndex(0), &solpos);
oapiGetGlobalPos(vessel->GetHandle(), &gpos);
MATRIX3 R;
oapiGetRotationMatrix(vessel->GetHandle(), &R);
toSun = tmul(R, solpos - gpos);
double ang_s = fabs(atan2(toSun.x, toSun.z)) / PI;
double ang_a = fabs(atan2(toSun.y, toSun.z)) / PI;
//double ang_r = fabs(atan2(toSun.x, toSun.y)) / PI;
return (ang_s + ang_a) / 2;
The above is tailored for another purpose; to take the vessel's AOA and slip angle to the sun, and return a number between 0-1, with 0 being pointed directly at the sun and 1 being pointed directly away. I keep trying to work with this as a starting-point but have found myself going round in circles. I don't think this is the right approach but I have reached an impass!
What I would like, is to be able to have a direction vector in local frame (for example 0,1,0: pointed straight up) and return the same 0-1 value based on this vector's angle to the sun. I need for the vector to be able to be dynamic, say for if I wanted it to rotate around the vessel, say starting as (0,1,0) and ending as (0,0,-1). Essentially this is for solar panel simulation, but I would like for the solar panel's direction to be able to be any direction (in case of solar tracking). I know this is probabloy a very roundabout way of tackling this, but I am developing this as part of an SDK, which is why I have need for such a universal-approach.
Thank you anyone who can help me with this, any help is greatly appreciated!
MrMartian