Re: [racket-users] Re: How to draw a 3D ball?

2015-07-21 Thread JK


Le 20/07/2015 11:03, Mianlai Zhou a écrit :

Hi,

Thanks for your answer. I meant the former, i.e., a 2D pict of a ball 
with some shading to make it look 3D.
Is there any quick way to do it or I have to implement the algorithm 
by myself?






The answer is more general than just in the context of Racket...
Do you want something of this kind (sorry for the quality, it was just a 
30 second test, it could be better).
The algorithm is just a radial gradient, and a clipping circle. Its 
'softness' translates visually into the amount of specularity, or the 
roughness, if you prefer. Some exquisite parametrization may be found 
anywhere, e. g. here (a page on SVG):


http://doc.qt.io/qt-5/qtsvg-svgviewer-files-spheres-svg.html

which gives:



See also the book
Flash 3D Cheats Most Wanted by Yard, Balkan, et al.

Now, the Racket solution ...
You will find the information about radial gradients (with examples) 
here, in your local doc:

... /doc/draw/radial-gradient_.html?q=gradient#%28tech._radial._gradient%29

On line:
http://docs.racket-lang.org/draw/radial-gradient_.html#%28tech._radial._gradient%29

To have something more realistic, you should combine (at least) the 
diffuse and specular lighting, which is non-linear. Quite easy, and 
implemented in the 3D simulation in SVG, and several drawing packages, 
but all depends on your ambitions. For simple drawings, a quite trivial 
CSS suffices, there is a radial gradient in the standard, and multiple 
colour stops are possible.


http://www.w3schools.com/css/css3_gradients.asp



Best regards

Jerzy Karczmarczuk
/Caen, France/




--
You received this message because you are subscribed to the Google Groups Racket 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How to draw a 3D ball?

2015-07-20 Thread Mianlai Zhou
Hi,

Thanks for your answer. I meant the former, i.e., a 2D pict of a ball with
some shading to make it look 3D.
Is there any quick way to do it or I have to implement the algorithm by
myself?

Thanks again.


On Mon, Jul 20, 2015 at 8:38 AM, Jack Firth jackhfi...@gmail.com wrote:

 On Saturday, July 18, 2015 at 7:30:42 PM UTC-7, Mianlai Zhou wrote:
  Hi all,
 
 
  I am wondering how to change the following code of a 2D circle into a 3D
 ball:
 
 
  (require slideshow)
  (colorize (filled-ellipse (* size 15) (* size 15)) red)
 
 
 
  My intention is to make the picture look like a real ball in
 3-dimension. Is there such
  a function existing already in Racket?
 
 
  Thank you in advance.

 By 3D ball do you want a 2D pict of a ball with some shading to make it
 look 3D, or a 3D model of a ball? If it's the latter you can use the pict3d
 package (raco pkg install pict3d):


 (require pict3d)
 (sphere origin 1)

 If you do this in DrRacket, the repl will show a window with a 3D ball
 model in it. You can click it and use the arrow keys to change the angle
 and position you view the ball from.

 --
 You received this message because you are subscribed to the Google Groups
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: How to draw a 3D ball?

2015-07-19 Thread Jack Firth
On Saturday, July 18, 2015 at 7:30:42 PM UTC-7, Mianlai Zhou wrote:
 Hi all,
 
 
 I am wondering how to change the following code of a 2D circle into a 3D ball:
 
 
 (require slideshow)
 (colorize (filled-ellipse (* size 15) (* size 15)) red)
 
 
 
 My intention is to make the picture look like a real ball in 3-dimension. Is 
 there such 
 a function existing already in Racket?
 
 
 Thank you in advance.

By 3D ball do you want a 2D pict of a ball with some shading to make it look 
3D, or a 3D model of a ball? If it's the latter you can use the pict3d package 
(raco pkg install pict3d):


(require pict3d)
(sphere origin 1)

If you do this in DrRacket, the repl will show a window with a 3D ball model in 
it. You can click it and use the arrow keys to change the angle and position 
you view the ball from.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.