1-- { dg-do compile } 2-- { dg-options "-O3" } 3 4with Opt18_Pkg; use Opt18_Pkg; 5 6package body Opt18 is 7 8 function Mag (Item : in Cart_Vector_Type) return Float is 9 begin 10 return Sqrt (Item (X) * Item (X) + Item (Y) * Item (Y) 11 + Item (Z) * Item (Z)); 12 end; 13 14 function Unit_Quaternion_To_Mag_Axis (Quaternion : in Unit_Quaternion_Type) 15 return Mag_Axis_Type is 16 Sin_Half : Float 17 := Mag (Cart_Vector_Type'(Quaternion.X, Quaternion.Y, Quaternion.Z)); 18 begin 19 if Sin_Half > 3.0 * First_Order_Trig then 20 return 21 (Mag => Atan2 (Double_Trig (Unchecked_Trig_Pair (Sin_Half, 22 Quaternion.S))), 23 Axis => Unit_Vector_Type'(Quaternion.X / Sin_Half, 24 Quaternion.Y / Sin_Half, 25 Quaternion.Z / Sin_Half)); 26 else 27 return (0.0, X_Unit); 28 end if; 29 end; 30 31end Opt18; 32