Go to Post No one said that this would be easy. And if they did, they were obviously refering to a little red button from Staples and not to FIRST. - artdutra04 [more]
Home
Go Back   Chief Delphi > Other > Math and Science
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-10-2013, 21:26
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
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: Geometry & Trig Quiz

Quote:
Originally Posted by Aaron.Graeve View Post
This could be fixed by using arcsin ((x1-x0)/sqrt ((x1-x0)^2+(y1-y0)^2)).
That actually made the problem worse. It gives the wrong answer if y1<y0.

For example: If x0=0, y0=0, x1=10, y1=-1, and alpha=90 degrees, that formula gives sigma= -5.7 degrees instead of the correct +5.7 degrees.

There's a simple alternative to arctan(dx/dy) that gives the correct angle for all values of dx and dy except when they are both zero.


Quote:
Regarding the smallest Delta, either a conditional check on the absolute value of Delta being larger than 180 degrees or running the delta through arcsin(sin(Delta)) could do the trick. I know the second suggestion is implemetation dependent and not the ideal method but it is a method that I think will work in most cases.
There's a calculation that produces the smallest angle without conditional logic or trig functions.


Reply With Quote
  #2   Spotlight this post!  
Unread 27-10-2013, 00:41
Happy Birthday! Aaron.Graeve Aaron.Graeve is offline
Registered User
FRC #1477 (Texas Torque)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: College Station, Texas
Posts: 103
Aaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to all
Re: Geometry & Trig Quiz

The simple alternative to atan(dy/dx) wouldn't happen to be atan2(dy, dx), would it? I am unsure if the problem permits us to use computer functions that happen to wrap up the conditonal logic nicely.

Edit: I just saw the thread with StangPS and the video. I see you did live up to your comments about disecting the math. Well played. I feel foolish for reinventing the wheel now.
__________________

2016:
Alamo, Bayou, and Lone Star Regional FTAA
2015:
Dallas, Alamo, Bayou, and Lone Star Regional FTAA
2014:
Alamo, Dallas, and Lone Star Regional FTAA
Alamo Regional Robot Inspector
2013:
Einstein Champion and 2013 World Champion (Thanks 1241 & 610), Galileo Division Champion, Razorback Regional Winner, Alamo Regional Semifinalist, Bayou Regional Semifinalist, Lone Star Regional Quarterfinialist
2012:
Curie Division Semifinalist, Lone Star Regional Finalist, Bayou Regional Winner, Alamo Regional Winner

Last edited by Aaron.Graeve : 27-10-2013 at 02:24.
Reply With Quote
  #3   Spotlight this post!  
Unread 27-10-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,077
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: Geometry & Trig Quiz

Quote:
Originally Posted by Aaron.Graeve View Post
The simple alternative to atan(dy/dx) wouldn't happen to be atan2(dy, dx), would it?
Yes it would. atan and atan2 have different behaviors.

atan's range is limited to -90 < atan < +90. So if the problem involves an angle like 95.7 degrees (as in the previously posted example), atan cannot return that value.

atan2's range is -180 <= atan2 <= +180 and it handles the quadrantal angles without crashing. Also, in many implementations (Octave is an example) atan2 handles the arguments (0,0) and returns 0.

You can wrap conditional logic around atan in your own code to produce your own version of atan2, but it's better to use the library version if it's available. Pages 152 thru 158 of P J Plauger's classic 1992 book The Standard C Library shows a reference implementation of atan and atan2.

I don't think you re-invented the wheel. Your diagram and accompanying explanation stated the simplifying assumptions explicitly, used a consistent reference coordinate system, and were very clear and easy to understand.


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 07:49.

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