Anonymous user
Draw a sphere: Difference between revisions
m
→{{header|Turing}}
Line 5,088:
% Absolute dot product of x and y
function dot (x, y : array 1 .. 3 of real) : real
result abs (x
end dot
% Vector normalization
procedure normalize (var v : array 1 .. 3 of real)
const norm := sqrt (v
for i : 1 .. 3
v
end for
end normalize
Line 5,102:
procedure drawSphere (radius : real, k : int, lightsource : array 1 .. 3 of real, brightness : real)
const diameter := 2.0 * radius
for i :
var x := i + 0.5
for j :
var y := j / 2 + 0.5
if x**2 + y**2 <= radius**2 then
var vec : array 1 .. 3 of real
vec
normalize (vec)
Line 5,213 ⟶ 5,211:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
</pre>
|