Go to Post I guess instead of focusing on the stuff we wish we could have changed, we should focus on all of the wonderful stuff we accomplished instead! - Winged Wonder [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #31   Spotlight this post!  
Unread 02-02-2013, 10:06
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: remainder function

Quote:
Originally Posted by Radical Pi View Post
drem() does exist, and is defined to be the same as remainder() (see the glibc manual).
Apparently in glibc, remainder() and drem() are two different names for the same function

Notice the very slight difference between the glibc and Java definitions (handling of divide-by-zero).



Last edited by Ether : 02-02-2013 at 11:26. Reason: fixed Java link
Reply With Quote
  #32   Spotlight this post!  
Unread 02-02-2013, 11:14
nightpool's Avatar
nightpool nightpool is offline
robotRectifier
AKA: Evan
no team (formerly of CORE 2062)
Team Role: Alumni
 
Join Date: Oct 2011
Rookie Year: 2011
Location: Waukesha, WI
Posts: 81
nightpool is on a distinguished road
Re: remainder function

The "java" link you posted was to gnu libc...
__________________
Proud alum of CORE 2062.
www.core2062.com
Reply With Quote
  #33   Spotlight this post!  
Unread 02-02-2013, 11:27
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: remainder function

Quote:
Originally Posted by nightpool View Post
The "java" link you posted was to gnu libc...
Fixed. Take a look.


Reply With Quote
  #34   Spotlight this post!  
Unread 08-02-2015, 16:56
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: remainder function

Quote:
Originally Posted by Joe Ross View Post
Here's the result from the robot

Code:
        double result;
        double x[] = {179, 180, 181, 359, 721, -1, -179, -180, -359, -361, -721};

        for (int i = 0; i < x.length; i++){
            result = MathUtils.IEEEremainder(x[i],360.0); 
            System.out.println("x: " + x[i] + " rem y: 360 result: " + result);
        }
Joe, is the MathUtils.IEEEremainder() method available in 2015 FRC Java, now that the runtime engine has changed? If so, does it produce the exact same results?


Reply With Quote
  #35   Spotlight this post!  
Unread 08-02-2015, 17:32
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: remainder function

Quote:
Originally Posted by Ether View Post
Joe, is the MathUtils.IEEEremainder() method available in 2015 FRC Java, now that the runtime engine has changed? If so, does it produce the exact same results?


It's in Math, rather then the squawk MathUtils workaround, but it still works.

Code:
x: 179.0 rem y: 360 result: 179.0
x: 180.0 rem y: 360 result: 180.0
x: 181.0 rem y: 360 result: -179.0
x: 359.0 rem y: 360 result: -1.0
x: 721.0 rem y: 360 result: 1.0
x: -1.0 rem y: 360 result: -1.0
x: -179.0 rem y: 360 result: -179.0
x: -180.0 rem y: 360 result: -180.0
x: -359.0 rem y: 360 result: 1.0
x: -361.0 rem y: 360 result: -1.0
x: -721.0 rem y: 360 result: -1.0
Reply With Quote
  #36   Spotlight this post!  
Unread 08-02-2015, 19:00
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: remainder function

Quote:
Originally Posted by Joe Ross View Post

It's in Math, rather then the squawk MathUtils workaround, but it still works.

Thanks Joe.

For those of you reading this thread for the first time, Math.IEEEremainder(angle,360.0) can be used to convert any angle (in degrees) to the range -180 to 180.

This can be very useful when working with the gyro.

Let's say you want to find the shortest angular error between your joystick direction angle and the gyro angle. This can be accomplished in one clean line of code as follows:

angle_error = Math.IEEEremainder(joystick-gyro,360.0);

There's no need for conditional logic. It cleanly handles all input angle ranges for joystick and gyro, including angles greater than 360 degrees and less than -360 degrees.

The above assumes that gyro and joystick share the same zero and measurement direction.


Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi