Thomas Dean

322 Reputation

10 Badges

19 years, 117 days

MaplePrimes Activity


These are questions asked by Thomas Dean

I have several plots generated with geometry objects:

plt1 := draw(...); plt2 := draw(...)

I want to display all them with a reasonable window.  I have been looping and and using a rather dumb proc to find the window size. I use the view=[...] option with the values calculated to set the plot view.

I wanted to post the proc, but, really messed that up!  I will try the proc later.

 

Some of the plots I am working with have views like

> for itm in [relBrgLinePlot,relTgtPositPlot,relTgtLinePlot] do
    op(-1,itm);
end do;
                     VIEW(0. .. 95., -61.58179461 .. 16.)
                 VIEW(5.48225506 .. 95., -61.58179461 .. 16.)
                 VIEW(5.48225506 .. 95., -61.58179461 .. 16.)

> for itm in [geoSensPositPlot,geoSensLinePlot,\
            geoBrgLinePlot,geoTgtPositPlot,geoTgtLinePLot] do
    op(-1,itm);
end do;
                  VIEW(0. .. 35.35331852, 0. .. 87.13244438)
                  VIEW(0. .. 35.35331852, 0. .. 87.13244438)
                     VIEW(0. .. 95., 0. .. 87.13244438)
                 VIEW(40.83557358 .. 95., 16. .. 25.55064977)
                 VIEW(40.83557358 .. 95., 16. .. 25.55064977)

Is there an easier way to do this?

Linux.  I want to put grid lines on an x11 device.

The x11 device is better for plotting because if the window is resized, the plot resizes with it.

restart;
plotsetup(x11);plot(sin(x),x=-1..1,gridlines = true); ## no gridlines

restart;
plotsetup(maplet);
plot(sin(x),x=-1..1,gridlines = true); ## have gridlines

Any way to get gridlines on x11 device?

Tom Dean

The first example is very slow compared to the second.  The difference is in the definition of f().

restart;
y := int(1/(-0.4016e-1*m^(2/3)-0.211e-3*m^(5/3)), m);
f:= unapply(abs(y), m):
n := 500: ## sample size
M := <seq(2*idx/n,idx=1..n)>; ## m
Y := f~(M)+~Statistics:-Sample(Normal(0,3), n)^+; ## signal + noise

restart;
y := int(1/(-0.4016e-1*m^(2/3)-0.211e-3*m^(5/3)), m);
f:= (x) -> abs(subs(m=x,y));
n := 500: ## sample size
M := <seq(2*idx/n,idx=1..n)>; ## m
Y := f~(M)+~Statistics:-Sample(Normal(0,3), n)^+; ## signal + noise


With a somewhat complicated equation for a line, draw fails.

with(geometry):

point(P1,[47+(38+22/60)/60, -(122+(43+4/60)/60)]);
point(P2,coordinates(P1) +~ [cos(30*Pi/180),sin(30*Pi/180)]);
line(L1,[P1,P2]);
Equation(L1);
draw(L1); ## no line

point(P1,[0,0]);
point(P2,[7,9]);
line(L1,[P1,P2]);
draw(L1);  ## works

Tom Dean

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[1]);
    tgtX := tgtX +~ ListTools[PartialSums](dt *~ tgtSpd *~ cos(tgtCse));
    tgtY := tgtRange*sin(Brg[1]);
    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[1] - y[1]    = m[1]*(tgtX[1]-x[1]):
eq2 := tgtY[2] - y[2]    = m[2]*(tgtX[2]-x[2]):
eq3 := tgtY[3] - y[3]    = m[3]*(tgtX[3]-x[3]):
eq4 := tgtY[4] - y[4]    = m[4]*(tgtX[4]-x[4]):
## target X motion along the target line
eq5 := tgtX[2] - tgtX[1] = tgtVx*(t[2]-t[1]):
eq6 := tgtX[3] - tgtX[2] = tgtVx*(t[3]-t[2]):
eq7 := tgtX[4] - tgtX[3] = tgtVx*(t[4]-t[3]):
## target Y motion along the target line
eq8 := tgtY[2] - tgtY[1] = tgtVy*(t[2]-t[1]):
eq9 := tgtY[3] - tgtY[2] = tgtVy*(t[3]-t[2]):
eq10:= tgtY[4] - tgtY[3] = tgtVy*(t[4]-t[3]):
##
#########################################################################
##
## 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);

 

First 11 12 13 14 15 Page 13 of 15