[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orekit Users] Advice on FastMath.toRadians

bogdan.udrea@vissidus.com a écrit :

Dear Colleagues,

This might be better asked on the Hipparchus listserv but I have decided to
ask it here as well.

I am using an XML file to store the parameters of a simulation where I specify
Euler angles for a multitude of sensors. The Euler angles are stored in the
XML file in degrees so they are easy to read by humans. The angles are
converted to radians in the code in a loop.

// Euler angles so that the Ox axis of sensors points radially out
// rotation order of Euler angles is ZYX
double [] senEulerAng = senParams.getEulerAngles();
for ( int i = 0; i < senEulerAng.length; ++i ) { // converts to rad
	senEulerAng[i] = FastMath.toRadians( senEulerAng[i] );

The question: Is it possible to apply FastMath.toRadians as an iterator on an
array of doubles? I haven't been able to figure it out on my own.

You may try this, if senEulerAng is declared as final so it is available in
the context of the lambda generator function:

   Arrays.setAll(senEulerAng, i -> FastMath.toRadians(senEulerAng[i]));

best regards,

A solution would be to convert the array of doubles to a RealVector,
mapMultiuply with pi/180, and then convert back to an array of doubles but it
seems like a workaround instead of elegant Java.

Thank you.