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

RE: [Orekit Users] Advice on FastMath.toRadians



Luc,

Thank you for your help. It works great. 
Lambda functions are new to me and now I see quite a few places where I can use them in the code.

Best regards,

Bogdan

-----Original Message-----
From: orekit-users-request@orekit.org <orekit-users-request@orekit.org> On Behalf Of MAISONOBE Luc
Sent: Thursday, July 19, 2018 10:23
To: orekit-users@orekit.org
Subject: 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,
Luc

>
> 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.
>
> Bogdan