# Calculating body frame X vector's look direction in GEO (NED) frame from roll, pitch and yaw data, is this correct?

I have roll, pitch and yaw angle values for a LEO satellite. Satellite orbit frame and spacecraft body frame are defined as LVLH. The satellite position and velocity are given in ECI/GEI frame. I have to find where the satellite x unit vector looks in GEO frame.

For this, I am first rotating the unit vectors in LVLH according to the given roll, pitch, yaw angles (the attitude sequence is X-Y-Z: roll-pitch-yaw). Then convert the LVLH frame vectors to ECI(GEI) frame with Z-X-Z sequence and continue to the coordinate transformations:

ECI-->ECEF-->NED

LVLH to ECI: Z-X-Z sequence

sat_raan = raan*(math.pi/180)    #right ascencion of ascending node in radians
sat_inc = inc*(math.pi/180)      #satellite inclination in radians
sat_ap = ap*(math.pi/180)        #argument of perigee in radians

body_GEIx[:, i]=R_z(sat_raan) @ R_x(sat_inc) @ R_z(sat_ap) @ body_x[:, i]*GEIx[i]
body_GEIy[:, i]=R_z(sat_raan) @ R_x(sat_inc) @ R_z(sat_ap) @ body_y[:, i]*GEIy[i]
body_GEIz[:, i]=R_z(sat_raan) @ R_x(sat_inc) @ R_z(sat_ap) @ body_z[:, i]*GEIz[i]


ECI to ECEF: Only Z rotation: Theta: Greenwich sidereal time + Earth's rotation

body_ECEFx[:, i]=R_z(Theta) @ body_GEIx[:, i]
body_ECEFy[:, i]=R_z(Theta) @ body_GEIy[:, i]
body_ECEFz[:, i]=R_z(Theta) @ body_GEIz[:, i]


ECEF to NED: Z-Y rotation

rlon= -1*(math.pi/2+ (lon[i]* (math.pi/180))) #convert to radians