A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
39
Task/Death-Star/J/death-star-1.j
Normal file
39
Task/Death-Star/J/death-star-1.j
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
mag =: +/&.:*:"1
|
||||
norm=: %"1 0 mag
|
||||
dot =: +/@:*"1
|
||||
|
||||
NB. (pos;posr;neg;negr) getvec (x,y)
|
||||
getvec =: 4 :0 "1
|
||||
pt =. y
|
||||
'pos posr neg negr' =. x
|
||||
if. (dot~ pt-}:pos) > *:posr do.
|
||||
0 0 0
|
||||
else.
|
||||
zb =. ({:pos) (-,+) posr -&.:*: pt mag@:- }:pos
|
||||
if. (dot~ pt-}:neg) > *:negr do.
|
||||
(pt,{:zb) - pos
|
||||
else.
|
||||
zs =. ({:neg) (-,+) negr -&.:*: pt mag@:- }:neg
|
||||
if. zs >&{. zb do. (pt,{:zb) - pos
|
||||
elseif. zs >&{: zb do. 0 0 0
|
||||
elseif. ({.zs) < ({:zb) do. neg - (pt,{.zs)
|
||||
elseif. do. (pt,{.zb) - pos end.
|
||||
end.
|
||||
end.
|
||||
)
|
||||
|
||||
|
||||
NB. (k;ambient;light) draw_sphere (pos;posr;neg;negr)
|
||||
draw_sphere =: 4 :0
|
||||
'pos posr neg negr' =. y
|
||||
'k ambient light' =. x
|
||||
vec=. norm y getvec ,"0// (2{.pos) +/ i: 200 j.~ 0.5+posr
|
||||
|
||||
b=. (mag vec) * ambient + k * 0>. light dot vec
|
||||
)
|
||||
|
||||
togray =: 256#. 255 255 255 <.@*"1 0 (%>./@,)
|
||||
|
||||
env=.(2; 0.5; (norm _50 30 50))
|
||||
sph=. 20 20 0; 20; 1 1 _6; 20
|
||||
'rgb' viewmat togray env draw_sphere sph
|
||||
54
Task/Death-Star/J/death-star-2.j
Normal file
54
Task/Death-Star/J/death-star-2.j
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
load'graphics/viewmat'
|
||||
|
||||
resolution=: 8
|
||||
spheres=: 3 1 #"1 ] 0 1,_1 1,:0.3 0.6 NB. spheres x y z r
|
||||
|
||||
|
||||
coordinates=: (% <:)~ (,"1 0~"0 3 ,"0"1 0~)@:i:
|
||||
length=: +/ &.: *:
|
||||
centers=: _ 3&{.
|
||||
radii=: _ _1&{.
|
||||
|
||||
NB. resolution SlicePittedSphere spheres generates a binary array, 1 in the geometric object
|
||||
SlicePittedSphere=: (0 { {. > [: +./ }.)@:(radii@[ >:"0 3 ((length@:-"1"_ 1 centers)~ coordinates))~
|
||||
|
||||
spanTo=: conjunction def '(m<:y)*.y<:n' NB. algebraic similarity, m <= y <= n
|
||||
|
||||
tessellate=: ] ];._3"3~ 3 # [ NB. All cubical edge length x subarrays of array y
|
||||
|
||||
NB. Define "faces" as those points with 9 to 18 inclusive "solid" neighbors.
|
||||
detectFace=: (9 spanTo 18) @: (+/@:,"3) @: (3&tessellate)
|
||||
|
||||
NB. arrange faces in ANSYS brick face order
|
||||
ThickFaces=: ((|:"3 , (, |:"2))(,: |."1)3 3 3$2j1#1) /: 'SENWDU' i. 'DUEWSN'
|
||||
ThinFaces=: ((|:"3 , (, |:"2))(,: |."1)3 3 3$1j2#1) /: 'SENWDU' i. 'DUEWSN'
|
||||
|
||||
FACES=:ThickFaces NB. 6 below comes from #Faces
|
||||
|
||||
NORMALS=: 2 tessellate FACES
|
||||
|
||||
matchNormals=: [: +/@,"6 NORMALS ="6"6 _ (2 tessellate 3 tessellate ])
|
||||
|
||||
bestFit=: (i.>./)"1&.|:
|
||||
|
||||
topFace=: detectFace i:"1 1:
|
||||
|
||||
choose=: 4 : 'x}y'
|
||||
|
||||
viewmat resolution (topFace choose (,&(#FACES))@:bestFit@matchNormals)@SlicePittedSphere spheres
|
||||
|
||||
|
||||
<"_1 ThickFaces NB. display the 6 cubes with reference faces
|
||||
┌─────┬─────┬─────┬─────┬─────┬─────┐
|
||||
│1 1 1│1 1 0│0 0 0│0 1 1│1 1 1│0 0 0│
|
||||
│1 1 1│1 1 0│1 1 1│0 1 1│1 1 1│0 0 0│
|
||||
│0 0 0│1 1 0│1 1 1│0 1 1│1 1 1│0 0 0│
|
||||
│ │ │ │ │ │ │
|
||||
│1 1 1│1 1 0│0 0 0│0 1 1│1 1 1│1 1 1│
|
||||
│1 1 1│1 1 0│1 1 1│0 1 1│1 1 1│1 1 1│
|
||||
│0 0 0│1 1 0│1 1 1│0 1 1│1 1 1│1 1 1│
|
||||
│ │ │ │ │ │ │
|
||||
│1 1 1│1 1 0│0 0 0│0 1 1│0 0 0│1 1 1│
|
||||
│1 1 1│1 1 0│1 1 1│0 1 1│0 0 0│1 1 1│
|
||||
│0 0 0│1 1 0│1 1 1│0 1 1│0 0 0│1 1 1│
|
||||
└─────┴─────┴─────┴─────┴─────┴─────┘
|
||||
14
Task/Death-Star/LSL/death-star.lsl
Normal file
14
Task/Death-Star/LSL/death-star.lsl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
default {
|
||||
state_entry() {
|
||||
llSetPrimitiveParams([PRIM_NAME, "RosettaCode DeathStar"]);
|
||||
llSetPrimitiveParams([PRIM_DESC, llGetObjectName()]);
|
||||
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SPHERE, PRIM_HOLE_CIRCLE, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.12, 1.0, 0.0>]);
|
||||
llSetPrimitiveParams([PRIM_ROTATION, <-0.586217, 0.395411, -0.586217, 0.395411>]);
|
||||
llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, ZERO_VECTOR, ZERO_VECTOR, 0.0]);
|
||||
llSetPrimitiveParams([PRIM_TEXT, llGetObjectName(), <1.0, 1.0, 1.0>, 1.0]);
|
||||
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0.5, 0.5, 0.5>, 1.0]);
|
||||
llSetPrimitiveParams([PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_HIGH, PRIM_BUMP_NONE]);
|
||||
llSetPrimitiveParams([PRIM_SIZE, <10.0, 10.0, 10.0>]);
|
||||
llSetPrimitiveParams([PRIM_OMEGA, <0.0, 0.0, 1.0>, 1.0, 1.0]);
|
||||
}
|
||||
}
|
||||
3
Task/Death-Star/Mathematica/death-star.mathematica
Normal file
3
Task/Death-Star/Mathematica/death-star.mathematica
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
RegionPlot3D[x^2 + y^2 + z^2 < 1 && (x + 1.7)^2 + y^2 + z^2 > 1,
|
||||
{x, -1, 1}, {y, -1, 1}, {z, -1, 1},
|
||||
Boxed -> False, Mesh -> False, Axes -> False, Background -> Black, PlotPoints -> 100]
|
||||
Loading…
Add table
Add a link
Reference in a new issue