Message Boards Message Boards

Find the right angle of a shot (SNOOKER)

Posted 4 years ago

Snooker is a fascinating sport. Just now the UK Championship is taking place.

I tried to visualize (in a 1st approximation, things are a bit more complicated in real life) how the cue ball covers an object ball when a certain angle is needed.

Look at the follwoing code. The left side of the resulting graphics shows the situation and the angle necessary to kick the opject-ball in the pocket, the right side shows the view from the cue ball to the object-ball for this shot.

Now I tried to make the right side of this graphic bigger (that does not work by increasing the r in the Sphere-statements), but without success. It seems that Manipulate renders a frame which could not be modified (at least in my version Mma 7). If you click on the right side of the picture that frame appears. As you see there is ample space above and below the spheres.

Is there a method to get rid of that space above and below the spheres? I tried PlotRange, ImageSize, ContentSize and many others, but nothing worked.

tT = {2, 2};
tT3 = {2, 2, 0};
r = .35;
gh = -2 r tT/Norm[tT];
obb = {0, 0};
dd = 3.;
gh3 = -2 r tT3/Norm[tT3];
obb3 = {0, 0, 0};

Manipulate[
 phi = phi1 Pi/180;
 cue = dd {Cos[3 Pi/4 + phi], Sin[3 Pi/4 + phi]};
 tTp = tT - gh;
 obbp = obb - gh;
 ghp = gh - gh;
 cuep = cue - gh;
 cue3 = dd {Cos[3 Pi/4 + phi], Sin[3 Pi/4 + phi], 0};
 tTp3 = tT3 - gh3;
 obb3p = obb3 - gh3;
 ghp3 = gh3 - gh3;
 cue3p = cue3 - gh3;
 vp = 10 cue3p/Norm[cuep];
 xx = Norm[cue3p - obb3p];
 GraphicsGrid[
  {{Graphics[
     {Red, Disk[obbp, r], Black, Circle[ghp, r], GrayLevel[.8], 
      Disk[cuep, r],
      Black, Line[{cuep, ghp, tTp}], Dashed, Circle[tTp, 2 r]}, 
     PlotRange -> {{-3, 3}, {-3, 3}}],
    Graphics3D[{White, Sphere[cue3p, r  ], Red, Sphere[obb3p, r ], 
      Black}, ViewPoint -> vp, Boxed -> False, 
     SphericalRegion -> True]}},
  ImageSize -> Large
  ], {phi1, 20, 160}]

Hints are appreciated.

POSTED BY: Hans Dolhaine
3 Replies
Posted 4 years ago

You could use the option ViewAngle

g2 = Graphics3D[
    {Red, Sphere[obb, r], White, Sphere[cue, r]},
    ViewPoint -> vp, Boxed -> False, SphericalRegion -> True,
    ViewAngle -> 2.2 \[Degree]
];
POSTED BY: Hans Milton

This is perhaps somewaht better, but the original problem remains.

r = .2;
d = 1.5;
f = 1.2;
obb = {0, 0, 0};
obb2 = {0, 0};
ghb = {0, -2 r, 0};
ghb2 = {0, -2 r};

Manipulate[
 phi = (270 + w) Pi/180;
 cue = d {Cos[phi], Sin[phi], 0};
 cue2 = Take[cue, 2];
 vp = ghb + (cue - ghb) 10;

 g1 = Graphics[
   {Red, Disk[obb2, r],
    GrayLevel[.8], Disk[cue2, r],
    Black, Circle[ghb2, r],
    Black,
    Line[{cue2, obb2}],
    Arrow[{obb2, {0, 1}}],
    Arrow[{cue2, ghb2}],
    Dashed, Line[{ghb2, obb2}]
    },
   PlotRange -> {f {-d, d}, f {-d, d}}
   ];

 g2 = Graphics3D[
   {
    Red, Sphere[obb, r],
    White, Sphere[cue, r]
    },
   ViewPoint -> vp,
   Boxed -> False,
   SphericalRegion -> True
   ];

 GraphicsGrid[{{g1, g2}}, ImageSize -> Large],
 {w, {-70, -60, -45, -30, 0, 30, 45, 60, 70}}, ControlType -> Setter]
POSTED BY: Hans Dolhaine

Dear Hans,

I guess this effect comes from the fact that the whole box (visible or not) is displayed. You can see this when you change in g2 the option to Boxed -> True. I do not have a clean solution for this. A sort of cropping would be necessary, consequently a "quick and dirty" way would be:

g2 = ImageCrop@
   Rasterize[Graphics3D[{Red, Sphere[obb, r], White, Sphere[cue, r],
      Gray, PointSize[.005], Point[{{0, 0, -.4}, {0, 0, .4}}]}, 
     ViewPoint -> vp, Boxed -> False, SphericalRegion -> True], 
    ImageResolution -> 200];

The points above and below are necessary to avoid rescaling.

Best regards -- Henrik

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract