# Question:Difficulty in Solving a Problem

## Question:Difficulty in Solving a Problem

Maple 2016

I have been working on a general solution to motion analysis and seem to be going backwards.  I have an numerical solution in Octave I use for comparison.  I have reduced the problem to a small example that exhibits the problem.

I posted a question similar to this, but, without a set of known values.

I am doing something wrong, but, what?

Tom Dean

## bearing.mpl, solve the target motion problem with bearings only.
##
## Consider a sensor platform moving through points (x,y) at times
## t[1..4] with the target bearings, Brg[1..4] taken at times t[1..4]
## with the target proceeding along a constant course and speed.
##
## time t, bearing line slope m, sensor position (x,y) are known
## values.
##
## Since this is a generated problem the target position at time t is
## provided to compare with the results.
##
#########################################################################
##
restart;
##
genKnownValues := proc()
description "set the known values",
"t - relative time",
"x - sensor x location at time t[i]",
"y - sensor y location at time t[i]",
"m - slope of the bearing lines at time t[i]",
"tgtPosit - target position at time t[i]";
global t, m, x, y, tgtPosit;
local dt, Cse, Spd, Brg, A, B, C, R, X;
local tgtX, tgtY, tgtRange, tgtCse, tgtSpd;
## relative and delta time
t := [0, 1+1/2, 3, 3+1/2];
dt := [0, seq(t[idx]-t[idx-1],idx=2..4)];
## sensor motion
Cse := [90, 90, 90, 50] *~ Pi/180; ## true heading
Spd := [15, 15, 15, 22];  ## knots
## bearings to the target at time t
Brg := [10, 358, 340, 330] *~ (Pi/180);
## slope of the bearing lines
m:=map(tan,Brg);
## calculate the sensor position vs time
x := ListTools[PartialSums](dt *~ Spd *~ map(cos, Cse));
y := ListTools[PartialSums](dt *~ Spd *~ map(sin, Cse));
## target values  start the target at a known (x,y) position at a
## constant course and speed
tgtRange := 95+25/32; ## miles at t1, match octave value...
tgtCse := 170 * Pi/180; ## course
tgtSpd := 10; ## knots
tgtX := tgtRange*cos(Brg);
tgtX := tgtX +~ ListTools[PartialSums](dt *~ tgtSpd *~ cos(tgtCse));
tgtY := tgtRange*sin(Brg);
tgtY := tgtY +~ ListTools[PartialSums](dt *~ tgtSpd *~ sin(tgtCse));
## return target position vs time as a matrix
tgtPosit:=Matrix(4,2,[seq([tgtX[idx],tgtY[idx]],idx=1..4)]);
end proc:
##
#########################################################################
## t[], m[], x[], and y[] are known values
##
## equation of the bearing lines
eq1 := tgtY - y    = m*(tgtX-x):
eq2 := tgtY - y    = m*(tgtX-x):
eq3 := tgtY - y    = m*(tgtX-x):
eq4 := tgtY - y    = m*(tgtX-x):
## target X motion along the target line
eq5 := tgtX - tgtX = tgtVx*(t-t):
eq6 := tgtX - tgtX = tgtVx*(t-t):
eq7 := tgtX - tgtX = tgtVx*(t-t):
## target Y motion along the target line
eq8 := tgtY - tgtY = tgtVy*(t-t):
eq9 := tgtY - tgtY = tgtVy*(t-t):
eq10:= tgtY - tgtY = tgtVy*(t-t):
##
#########################################################################
##
## solve the equations
eqs  := {eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10}:

Sol:= solve(eqs, {tgtVx, tgtVy, seq([tgtX[k], tgtY[k]][], k= 1..4)}):
##

genKnownValues():
## these values are very close to Octave
evalf(t);evalf(m);evalf(x);evalf(y);evalf(tgtPosit);
## The value of tgtX[] and tgtY[] should equal the respective tgtPosit values
seq(evalf(eval([tgtX[idx],tgtY[idx]], Sol)),idx=1..4); ﻿