94 this.tx_ball= imread(fullfile(fileparts(mfilename(
" fullpath ")),
" tx_golfball.png "));
96 this.tx_rasen= imread(fullfile(fileparts(mfilename(
" fullpath ")),
" tx_rasen.png "));
110 if isa(this.
ODESolver,
" solvers.MLWrapper ")
115 error(
" Not working with non-MatLab solver wrappers. ");
131 area = this.
Green.area;
132 status = status || ...
133 ~(x(1)<=area(2) && x(1)>=area(1)) && (x(2)<=area(4) && x(2)>=area(3));
139 status = status || ...
140 ((norm(v) < sys.maxvforhole) && (norm(x-mu(5:6))<this.
rad_hole));
147 status = status || ...
148 ~((norm(v) > this.
vmin) || (norm(gradient) > 0.040));
158 filename = fullfile(fileparts(mfilename(
" fullpath ")),
" default.mat ");
159 elseif exist(filename,
" file ") ~= 2
160 filename_ = fullfile(fileparts(mfilename(
" fullpath ")),filename);
161 if exist(filename_,
" file ") == 2
162 filename = filename_;
164 filename_ = fullfile(fileparts(mfilename(
" fullpath ")),[filename
" .mat "]);
165 if exist(filename_,
" file ") == 2
166 filename = filename_;
168 error(
" Invalid file name: %s ",filename);
177 g.hills= s.(
" hills ");
187 phi = linspace(0,2*pi,50);
188 theta = linspace(0,pi,50);
189 [PHI,THETA]=meshgrid(phi,theta);
190 this.HX_= sin(THETA).*cos(PHI);
191 this.HY_= sin(THETA).*sin(PHI);
201 hills = this.
Green.hills;
203 for numhill = 1:size(hills,1)
204 rad = -log(0.05)/hills(numhill,4)^2;
205 z = z + hills(numhill,3) * exp(-((x-hills(numhill,1)).^2 +(y-hills(numhill,2)).^2)*rad);
220 hlp = this.
green(x(1),x(2));
221 dx = 1/h*[this.
green(x(1)+h,x(2))-hlp ; this.
green(x(1),x(2)+h)-hlp];
235 map([1 2 3]) = [0 0 0];
237 map = [map; [zeros(steps+1,1) (0:1/steps:1)^
t zeros(steps+1,1)] ];
248 HX = mu(5) + this.
rad_hole*this.HX_;
249 HY = mu(6) + this.
rad_hole*this.HY_;
250 HZ = this.
green(HX,HY);
255 ax = pm.nextPlot(
" golf ",
" Trace of golf ball ",
" [x] = m ",
" [y] = m ");
257 set(gcf,
" Name ",
" Modellierung ",
" Renderer ",
" opengl ");
261 [x,y] = meshgrid(a(1):this.
detail:a(2),...
264 hGreen = surfl(ax,x,y,z);
269 set(hGreen,
" AmbientStrength ",.75);
270 light(
" Position ",[0 0 5],
" Style ",
" local ");
271 set(hGreen,
" FaceLighting ",
" phong ",
" AmbientStrength ",1)
279 hHole = surfl(ax,HX,HY,HZ+0.01);
281 set(hHole,
" CData ",0,
" FaceColor ",
" texturemap ");
313 oldgr = this.
green(y(1,1),y(2,1));
318 oldoffset = [-this.
gradgreen([y(1,1) y(2,1)]); 1];
319 oldoffset = this.rad_ball * oldoffset / norm(oldoffset);
322 [BX,BY,BZ] = sphere(50);
323 hBall = surfl(ax,this.rad_ball*BX + y(1,1)+oldoffset(1),...
324 this.rad_ball * BY + y(2,1)+oldoffset(2),...
325 this.rad_ball* BZ + oldgr +oldoffset(3));
331 set(hBall,
" CDATA ",this.tx_ball,
" FaceColor ",
" texturemap ");
336 for index = 2:size(y,2)
339 gr = this.
green(y(1,index),y(2,index));
342 rel_move = [y(1,index)-y(1,index-1); y(2,index)-y(2,index-1); gr-oldgr];
346 rot_axis = [-rel_move(2) rel_move(1) 0];
349 plot3([y(1,index-1)+0.01 y(1,index)+0.01], [y(2,index-1)+0.01 y(2,index)+0.01], [oldgr+0.01 gr+0.01],
" r ");
369 offset = [-this.
gradgreen([y(1,index) y(2,index)]); 1];
370 offset = this.rad_ball * offset / norm(offset);
374 absmove = rel_move-oldoffset+offset;
377 set(hBall,
" XData ",
get(hBall,
" XData ")+absmove(1));
378 set(hBall,
" YData ",
get(hBall,
" YData ")+absmove(2));
379 set(hBall,
" ZData ",
get(hBall,
" ZData ")+absmove(3));
382 alpha = 360 * norm(rot_axis)/ball_circ;
384 center = [y(1,index)+offset(1) y(2,index)+offset(2) gr+offset(3)];
387 rotate(hBall,rot_axis,alpha,center);
393 title(strcat(
" Zeit: ",num2str(
t(index)),
" s, v= ",num2str(norm((y(:,index)-y(:,index-1))*1/
dt)),
" m/s "));
424 m = models.golf.Model(
" 4_2 ");
426 m = models.golf.Model(
" 4_3 ");
428 m = models.golf.Model(
" 4_4 ");
430 m = models.golf.Model(
" 4_5 ");
433 m = models.golf.Model(
" bsp1 ");
435 m = models.golf.Model(
" bsp2 ");
437 m = models.golf.Model(
" bsp3 ");
439 m = models.golf.Model(
" bsp4 ");
442 m = models.golf.Model;
function loadGreen(filename)
LOADGREEN Loads a stored golf setting.
BaseModel: Base class for both full and reduced models.
double dt
The desired time-stepsize for simulations.
static function res = test_Golf()
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
function dx = gradgreen(colvec< double > x)
Gradient von g.
rad_ball
Golfballradius in Meter gut: 0.015 m (42mm Durchmesser von Wikipedia)
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
function [ double t , colvec< double > x , double ctime ] = computeTrajectory(colvec< double > mu,integer inputidx)
logical LeaveOpen
Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) ...
System(models.BaseFullModel model)
solvers.BaseSolver ODESolver
The solver to use for the ODE. Must be an instance of any solvers.BaseSolver subclass.
mu
The current parameter for simulations, [] is none used.
double T
The final timestep up to which to simulate.
function status = ODE_Callback(double t,matrix< double > y, flag)
colvec< double > DefaultMu
The default parameter value if none is given.
function map = golfcolormap()
function ax = initPlot(pm)
Plotgreen: Zeichnet das Putting-Green und das zugehörige Loch.
function z = green(colvec< double > x,matrix< double > y)
Green - Erzeugt eine Hügellandschaft mit gegebenen Parametern.
function plot(double t,matrix< double > y, pm)
global rad_ball BX BY BZ t hFigure sol;% hBall;