Luca Moroni shared this question 4 years ago

I've recently uploaded a new material named Basketball 3D, available in the material section here.

I've spent much time in trying to refine it and I did all I could.

But much more refinements could be done with the help of the community.

From my didactic perspective it could help students to playfully discover the properties of the parabolic motion and to understand the concept of flux of a vector field (ball velocity) through a surface (the one delimited by the basketball ring).

I also wanted to explore the limits of what can be done with Geogebra in building a complex simulation and I'm rather impressed with the width of its opportunities, especially through the scripting and with its (rather hidden) resources.

I hope that some member of the community can contribute to the development of this project with comments and/or suggestion.

1

Hi Luca,

I have just seen your material. I think it is fantastic. I have a few suggestions.

I. I would put the stats in a table or box in tex:

II. Reset the time to 0 every time I drag the sliders (angles and v_0) and when I move the player.

III. You can change the 3d view by clicking and dragging the mouse, but I would add a button for changing the view quickly:

1. Create a slider called 'faces':

faces=Slider[0, 4, 1, 1, 100, false, true, false, false]

2. Create vectors:

u_1=(1,0,0)

u_2=(0,1,0)

u_3=(0,0,1)

u_4=(1;120°;-20°)

2. Create list with vector direction:

listvectordirection={u_1,u_2,u_3,u_4}

3. Define a selection:

Selectedvector=Element[listvectordirection, faces]

4. Create button with the following Script:

SetValue[faces,faces+1]

SetViewDirection[Selectedvector]

If[faces==4,SetValue[faces,0]]

But these are just simple suggestions that I would add. The material is pretty cool. Thanks for sharing. :)

Caio...

1

Hi Juan Carlos.

I'll surely implement number I (I didn't know about the TableText command before your hint).

I won't follow your suggestion II. Probably the function of the timer is not clear (I'll add some explanation in the material notes)

In fact in game mode (not yet fully implemented) with the countdown timer running, the ability of the player is to be quick and to find the right angles and v0 in the shortest possible time. So the player will make many shots in the game time limit. For instance if the game time is set to 120 s a well trained player will be able to make about 12/15 shots. If the positioning is accurate he will score many points. On the contrary a beginner player will score less because he's slow in the positioning or because he's inaccurate.

III for the time being I prefer using the mouse for positioning. Anyway I'll try your solution and check how goes.

I'll work on these improvements in the next weekend. I'll cite you as a contributor in the worksheet footnotes.

1

A final comment. I was just playing with your material and I have just found that sometime it tells me that I failed, when clearly the ball is going through the basket.

1

I noticed the same thing.

Marvelous app :o)

M

1

Thanks Juan Carlos Ponce Campuzano and mrahikka

No, I think the math is Ok.

You should check the trajectory (manually moving the t slider) not just when the ball center goes through the ring, but also some instant before and after.

The shoot is marked as "Fail" if the ball trajectory just touches the ring, even if the touching is barely visible.

[technical detail: the ring disk is projected in a plane perpendicular to the tangent of the trajectory when the ball center hits the ring center. Lets call this projection the effective ring disk. Let's also call r_2 the radius of the effective ring disk and O_2 its center. The condition for a Fail is when the ball center hits the effective ring disk in a point P with P 0_2 >= r_2-r_ball]

Anyway I understand that this could be a too strict condition and not match the visual impression. Furthermore in real basketball a light touch with the inner ring and a minimal bounce doesn't compromise the success of a shoot. So I'll add some tolerance (say 1/10 of the radius of the ball) to allow for a small grazing with the inner ring to be a success.

1

Perhaps, before plotting a whole vector field, it should be helpful to show the sum of the velocities at the time t, first.

1

Thanks

Interesting suggestion. But I'd like to keep the scene as clear as possible. I could consider to add it as an option (checkbox).

1

Following the suggestion received I've uploaded a new version of the applet.

Changes are:

• Better statistics text box (in latex) following the advice of Juan Carlos Ponce Campuzano.
• Clickable text boxes for changing the POV (thanks to Juan Carlos Ponce Campuzano)
• Some tolerance for avoiding a "Fail" result when there is a very small "grazing" (barely noticeable) of the ball with the inner ring (thanks to Juan Carlos Ponce Campuzano and

mrahikka). The default value is 0.2 (variable "tol") meaning that the "effective" surface of the ring is increased by 20%.

Any new suggestion is welcome!

Thanks

2

Hi,

an other way, with script...(see pink objects)

(approximation...just for fun...)

1

Wow Patrick!

I'm truly impressed by your suggestion. Great!

I didn't even dare to think that reproducing the bounces of the ball when hitting the basket ring or the backboard (and I'd add the floor) was reasonably feasible with Geogebra.

Seeing your code I see that it can be done and that it can add much more realism to the simulation.

The idea of reflecting the velocity vector in the element of impact is very smart and opens up new perspectives about how to manage the bounces.

Surely adding bounces in the overall scheme of the simulation will quite raise the complexity of the applet (i.e. understanding when the ball actually goes through the basket in the case of multiple bounces) but I think it's well worth it.

Your discrete step integration method is simple and smart but I'll also see if it's possible to use the exact parabolic trajectory (with initial conditions updated after each hitting of an obstacle)

I'll also see about inserting some sort of damping (in each impact and/or during the ball free flight).

Unfortunately I can't spend much time to these intended updates at the time being. So I'll come back to it in some weeks with the goal of integrating bounces (and damping) in the simulation

1

Hi Luca,

or :

try to fix bug :

...

more exact egal less velocity...

...

1

I'm studying the materials you pointed out to me and definitely I'll try to insert bounces in the Basketball3D simulation, even if it will take some time.

In the meantime I've prepared a short demo video (on youtube) of the version without

bounces, just to show how smooth is the material when run locally on a

PC, differently from running it through a browser or with a

smartphone/tablet as most Geogebra users probably do.

In the future plan (adding bounces) I can foresee three possible strategies:

1) Make Geogebra sort of a deterministic omniscient machine (a la Laplace): given the initial conditions, the rules for bounces (perfect elastic collision), and the rules of the parabolic motion the whole trajectory could theoretically be anticipated and computed just from the start (in case of bounces it will be a triple of piecewise functions for the 3 coordinates of the center of the ball).

2) Use a numerical integration method as in most materials dealing with this problem I've seen so far and reflect the trajectory about the obstacles when a collision is detected.

3) A mix of 1) and 2): recompute the exact parabolic motion (without numerical integration) each time a collision is detected.

I think alternatives 2) and 3) are the most appealing ones and 1) isn't probably actually viable.

1

Hi Luca,

1)

Make Geogebra sort of a omniscient

machine:

given the initial conditions, the rules for bounces (perfect elastic

collision), and the rules of the parabolic motion the whole

trajectory could theoretically be anticipated

and computed just from the start (in

case of bounces it will be a triple of piecewise functions

for the 3 coordinates of the center of the ball).

You right : no way with GGB.

2)

Use a numerical

integration method

as in most materials dealing with this problem I've seen so far and

reflect the trajectory about the obstacles when a collision is

detected.

Have you try and anderstand :

?

3)

A mix of 1) and 2): recompute

the exact parabolic motion (without

numerical integration) each time a collision is detected.

I'm agree : It

would be possible to recognize the collision and create an animation

based on these different collisions, if it does not take into

account the time... The animation speed will never be

respected! (or too difficult...)

1

Hello Everybody,

Patrick your update is awesome... I have seen the other worksheets you have. They are very cool. I will study them to make a worksheet about diffusion. In particular I am interested in this worksheet that you made: https://www.geogebra.org/m/...

I may need to ask you for some advice in the future.

Thanks...

1

I've finally completed a new version of the worksheet Basketball 3D with the addition of rebounds ﻿against the backboard and the rim together with the ball bounces when hitting the floor.

The worksheet is published in the Geogebra material repository here

The .ggb file is also attached in this post together with a short pdf guide explaining the meaning of some of the objects-parameters.

Given the complexity of the simulation it's highly advisable to run the ggb file through Geogebra classic desktop program and not with the web app.

Adding rebounds was not an easy task but greatly enhances the realism of the simulation.

It also enrich the shooting practice with the possibility of rimshots and bankshots.

Here's a short explanation about the underlying mechanism.

1. The ball position is driven by the t slider.
2. Initially the ball follows a 3D parabola (set as a parametric curve) fixed by the initial conditions (player position, shot direction and initial speed).
3. The distance of the ball from the possible obstacles (backboard, basket ring and floor) is continuously monitored.
4. If an impact is detected the time of impact is recorded and new initial conditions are evaluated (mainly by the reflection of the velocity vector in the obstacle object).
5. Then, after the impact, there is then a new starting time and a new initial condition and the ball will follow a new parametric parabola.
6. The process can be repeated till the maximum t value, and there's no need to know in advance how many rebounds there will be.

I'd call this construction "semi-deterministic" since the ball position is given by an exact function between two consecutive rebounds, but the time of impact is not deterministically determined in advance. In fact it depends on the fineness of the discreet time values in which Geogebra can make its calculation, the randomness of this time values and the machine processor speed.

For above reasons replaying a shot with the same initial condition can give different results after the first rebound. Furthermore there is an intrinsic irreversibility of the simulation with time.

In a way I like this stochastic behavior that resembles well what happens in many complex situations of the real world when the dynamical evolution of a physical model can't be described by mathematical equations in a closed form.

On the other hand the resulting computational complexity of this simulation seems oversized with respect of a simple model that, in the context of the classical physics equations of parabolic motion could be theoretically handled by a single deterministic piecewise function, where all the impacts and rebounds are calculated at time zero.

So I think I'll next explore if it's possible to achieve a fully deterministic construction strategy.

1

I've finally made up a first "beta version" of the simulation with exact trajectories (sort of fully deterministic as explained in the previous post).

The .ggb file is attached to this post. To try it download the file and run it locally in your desktop PC through the Geogebra Classic desktop program.

The file it's also available as a material in the page https://www.geogebra.org/m/jM3YvFaw but beware, running it through the Geogebra app and the web interface doesn't work as the calculations are too demanding.

I post this message in the hope to receive some help/support from some Geogebra interested users/developers, get some useful advice/comment and some insight in solving some of the following issues:

• The simulation often becomes slow and jerky after some trials (with the

time slider no more running as smoothly as at the beginning). I suspect

this could be due to some problem in Java/Geogebra memory management

when the complexity of the simulation and the amount of calculations

required are, like in this case, very demanding.

If that happens the only solution I've found is to quit Geogebra and start it again. I've tried to use the UpdateConstruction[ ] command in the script of the Reset button but it doesn't seem to really heal the problem. Anyway Geogebra seems to stand for the complexity of the simulation at the beginning (when the file is opened and run the first times).

• There might be errors in case of very complicated subsequent rebounds with the rim. Please help me to find them.

I'm aware that the construction is presently quite a mess (result of stratified development) and that there are many objects no more used in the interface presented.

In case the main issues could be solved and the necessary relevant changes to the optimal design identified the next steps will be devoted to a full streamlining of the whole process.