This sounds promising. That said, I tried the above steps (adding: as preparation steps, downloading http://www.jsoftware.com/jwiki/BrianSchott/code/turtleGraphics/tgsjhs?action=AttachFile&do=get&target=tgsjhszip.png as tgsjhszip.zip, creating a directory at j64-803-user/projects/tgsjhs and unzipping it there, and saving the code you presented as j64-803-user/catmullclark.ijs ...
However, nothing displays for me from the updated dp command. No error messages, no display update. I get the initial canvas from loading the window, and fd 20 moves the turtles, but that's all. Hitting enter in the ijx window doesn't give me anything (except position boxes from the other steps of the process). Do I need an updated version of tgsjhs? Thanks, -- Raul On Wed, Dec 3, 2014 at 9:37 PM, Brian Schott <[email protected]> wrote: > A rather laborious rendering of a wireframe graphic can be achieved with > JHS. If you would like to pursue it I have produced some small code and > some steps to use, shown below. The verb 'dp' is the main addition to your > work and the tgsjhs system. Another alternative, I gather, is Three.js with > JHS but I am not able to use it myself. > > NB. catmullclark.ijs > NB. 12 3 2014 > > avg=: +/ % # > > havePoints=: e."1/~ i.@# > > catmullclark=: 3 :0 > 'mesh points'=. y > face_point=. avg"2 mesh{points > point_face=. |: mesh havePoints points > avg_face_points=. point_face avg@#"1 2 face_point > edges=. ~.,/ meshEdges=. mesh /:~@,"+1|."1 mesh > edge_face=. *./"2 edges e."0 1/ mesh > edge_center=. avg"2 edges{points > edge_point=. (0.5*edge_center) + 0.25 * edge_face +/ .* face_point > point_edge=. |: edges havePoints points > avg_mid_edges=. point_edge avg@#"1 2 edge_center > n=. +/"1 point_edge > 'm3 m2 m1'=. (2,1,:n-3)%"1 n > new_coords=. (m1 * points) + (m2 * avg_face_points) + (m3 * avg_mid_edges) > pts=. face_point,edge_point,new_coords > c0=. (#edge_point)+ e0=. #face_point > msh=. (,c0+mesh),.(,e0+edges i. meshEdges),.((#i.)~/$mesh),.,e0+_1|."1 > edges i. meshEdges > msh;pts > ) > > points=: _1+2*#:i.8 > mesh=: 1 A."1 I.(,1-|.)8&$@#&0 1">4 2 1 > > rankinc =: ,@]$~-@[{.!.1 $@] NB. increase rank of y to x's value > mat =: 2&rankinc NB. increase rank of y to a matrix > > dp =: 3 : 0 > 0 dp y > : > 'msh pts' =. y > position =. x{Position > pts =. 30*pts > for_m. i. #msh do. > pu x > pt =. m{msh > x goto (mat position)+"1 pts{~pt{~0 > pd x > x goto (mat position)+"1 pts{~pt{~1 > x goto (mat position)+"1 pts{~pt{~2 > x goto (mat position)+"1 pts{~pt{~3 > end. > ) > > > Below are the steps required. > > 0 launch jhs > > 1 in jhs enter the following commands > load'~user/projects/tgsjhs/tgsjhs.ijs' > coclass'tgsj' > load'~user/catmullclark.ijs' NB. or whatever you named the file > > 2 in a new tab enter the following address > http://127.0.0.1:65001/tgsj > > 3 in the field where you see 'fd 20', instead enter the following, eg. > dp catmullclark mesh;points > > 4 you can see various different views by moving the focus from the input > field > elsewhere and then using the arrow keys > > 5 if you want to try another mesh and points, first press the "Restart" > button > > > > > > On Sun, Nov 30, 2014 at 10:18 AM, Raul Miller <[email protected]> wrote: > >> The Catmull-Clark surface subdivision algorithm is a fun little algorithm: >> >> http://rosettacode.org/wiki/Catmull%E2%80%93Clark_subdivision_surface >> http://rosettacode.org/wiki/Catmull%E2%80%93Clark_subdivision_surface#J >> >> But there are other approaches to this task, and some of them require >> very different sorts of abstractions. >> >> But testing the result - especially when the result is not exactly >> equivalent but only visually similar - requires a way of visualizing >> the results. Basically, you need a decent rendering system (one that >> gives lighting effects to represent the orientation of surfaces). >> >> Meanwhile, I've not been spending much time with all of the >> possibilities we have here. >> >> What are some of the current best 3d rendering systems we have in J? >> (Bonus question: what does the data structure for a medium-grey or >> green cube look like, for each such system?) >> >> Thanks, >> >> -- >> Raul >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > > > -- > (B=) > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
