Calculation of Roll and Pitch Factors in Custom Motor Matrix

Hi,
I am trying to deive the mixer matrix for my custom airframe for multicopter. Can anyone please provide the mathematical equations to derive the roll and pitch factor? Also, in Ardupilot I see that we can represent roll factor and pitch factor in terms of sine and cosine? In ardupilot while defining mixer matrix for any airframe they use an angle say theta and use roll_factor=cos(90+theta) and pitch_factor=cos(theta), but I do not know the theory behind this equation. How are they getting the angles?

Thanks,
Sayan

Found it! We just need to calculate the angles of the rotor positions with respect to x and y axis where x axis is vertical axis and y axis in horizontal axis and right side of x axis is +ve angle and the left side -ve angle.