
Computer Science Computer Science Forum 
 LinkBack  Thread Tools  Display Modes 
February 11th, 2012, 08:31 PM  #1 
Joined: Feb 2012 Posts: 2 Thanks: 0  Help with a relative motion/geometric problem
Hi, I'm not sure if this is the right forum to ask this question but here it goes: I'm trying to write a program that simulates an old but simple target tracking device used on ships in WWII but I've been having problems trying to understand how to use a few geometrical equations in a code. The program should be able to come up with new ranges and bearings over time based on initial values. Here are the equations in question, pgs 2425 of this 1944 manual: http://www.hnsa.org/doc/tdc/pg024.htm http://www.hnsa.org/doc/tdc/pg025.htm The terminology for the variables can be found here on pgs. 13/15: http://www.hnsa.org/doc/tdc/pg013.htm http://www.hnsa.org/doc/tdc/pg015.htm I'm trying to figure out how to calculate delta R from equation VIII on pg25 and delta B equation X on pg25. This is the "wrong" quick code I came up with in C# for testing (I'm sure I'm missing something): Code: public partial class Form1 : Form { float R, B, So, St, Co, Ct, A, Br, iR, iB; float dR, dB, dt; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //********** RANGES iR = 5000; // Initial range in yards R = iR; // Range //********* COURSES AND SPEEDS Ct = 120; // Target course in degrees St = 10 * 0.5626f; // Target speed in knots (converted to yards/sec) Co = 270; // Ownship course So = 5 * 0.5626f; // Ownship speed in knots (converted to yards/sec) //************** ANGLES Br = 25; // Relative target bearing iB = Co + Br; // Initial true target bearing in degrees B = iB; // True target bearing A = 180 + B  Ct; // Target angle //********** INSTANTANEOUS CHANGES dB = 0; // Instantaneous change in true bearing dR = 0; // Instantaneous change in range dt = 1f; // time step? for (float t = 1f; t < 1000f; t += dt) { dR = dR + (St * (float)Math.Cos(DegToRad(A)) + So * (float)Math.Cos(DegToRad(Br))); R = iR  dR; dB = dB + ((St * (float)Math.Sin(DegToRad(A)) + So * (float)Math.Sin(DegToRad(Br)))*t) / R; B = iB + dB; if (B > 360) B = B % 360; if (B < 0) B = B + 360; if (B > 359.5 && B < 360.5) B = 0; Br = B  Co; if (Br > 360) Br = Br % 360; if (Br < 0) Br = Br + 360; if (Br > 359.5 && Br < 360.5) Br = 0; A = 180 + B  Ct; if (A > 360) A = A % 360; if (A < 0) A = A + 360; if (A > 359.5 && A < 360.5) A = 0; listBox1.Items.Add( "t = " + t.ToString("000.00") + " Range (R) = " + R.ToString("0000") + " True Bearing (B) = " + B.ToString("000.00") + " Relative Bearing (Br) = " + Br.ToString("000.00") + " Angle A = " + A.ToString("000.00") + " dB = " + dB.ToString("0.0000") + " dR = " + dR.ToString("0.0000")); } } double DegToRad(float dd) { return (double)(0.0174532925f * dd); } } http://www.hnsa.org/doc/tdc/pg220.htm ...the new range and bearing results aren't even close to the values shown. What I'm not understanding is how to integrate the equations over time and how to keep track of time in seconds or minutes(not in real time I mean). If any of you guys have ideas on how to correctly code these equations (in C# or any other language) I'd really appreciate! I'm sorry if this seems like a very basic question, but I'm just not seeing how to solve it. Thanks! 
February 12th, 2012, 05:47 AM  #2 
Global Moderator Joined: Nov 2006 From: UTC 5 Posts: 14,500 Thanks: 557 Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic  Re: Help with a relative motion/geometric problem
One possibility: you put angles in degrees, but C# expects them to be in radians.

February 12th, 2012, 12:11 PM  #3  
Joined: Feb 2012 Posts: 2 Thanks: 0  Re: Help with a relative motion/geometric problem Quote:
 

Tags 
motion or geometric, problem, relative 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Physics: Projectile Motion/Relative Motion  edwinandrew  Physics  0  February 26th, 2014 04:30 PM 
relative rate of moving problem  asifrahman1988  Calculus  1  March 17th, 2013 03:24 AM 
Uniform Relative Motion in 3D  inkliing  Calculus  1  March 2nd, 2010 01:46 PM 
Relative Motion Question  Billy Madison  Applied Math  2  November 18th, 2007 01:27 AM 
[Research problem] A line & a circle w/ relative velocities  Solarmew  Algebra  0  January 1st, 1970 12:00 AM 