1 #import <Foundation/Foundation.h>
2 #import <AppKit/AppKit.h>
3 
4 #import <math.h>
5 #import <string.h>
6 
7 #define DIMENSION 300
8 #define DELTA     1e-8
9 
10 #define SCRAMBLE  200
11 
12 typedef struct {
13     double x, y, z;
14     int index;
15 } Vertex, *VPtr;
16 
17 typedef enum {
18     VIS_F_1 = 1,
19     VIS_F_2,
20     VIS_F_3
21 } VISIBILITY;
22 
23 typedef enum {
24     ROT_X = 0,
25     ROT_Y,
26     ROT_Z
27 } ROT_ACTIVE;
28 
29 @interface Rubik : NSView
30 {
31     id con;
32 
33     Vertex vertices[8];
34     Vertex indexed[8];
35     Vertex active[8];
36     Vertex sorted[8];
37 
38     double angle;
39 
40     ROT_ACTIVE rprev, rcur;
41 
42     VISIBILITY vis;
43     int visface[3];
44 
45     int face[6][4];
46     int adjacent[6][4];
47     int edge[6][4];
48 
49     NSColor *colors[8];
50     int data[6][3][3];
51 }
52 
53 - initAtPoint:(NSPoint)aPoint controller:(id)theCon;
54 
55 - resetCube;
56 
57 - scramble;
58 
59 - rotate:(Vertex *)vp aboutUnitVector:(ROT_ACTIVE)rv
60    angle:(double)theta;
61 
62 - recomputeGeometry;
63 
64 - angle:(id)sender;
65 
66 - (BOOL)solved;
67 
68 - (void)drawRect:(NSRect)aRect;
69 
70 - (int)visFaceClicked:(NSPoint)loc;
71 
72 - rotateFace:(int)f clockwise:(BOOL)flag;
73 
74 - (void)mouseDown:(NSEvent *)theEvent;
75 - (void)rightMouseDown:(NSEvent *)theEvent;
76 
77 @end
78 
79