﻿ C-Space Coordinates
SilverScreen Solid Modeler

# C-Space Coordinates  # C-Space Coordinates    W-Space, C-space, and E-Space

SilverScreen supports three types of coordinate systems: W-Space (world space), C-Space (construction space), and E-Space (entity space).

The W-Space coordinate system corresponds to the standard Cartesian coordinate system.  C-Space refers to a three-dimensional coordinate system that can be oriented anywhere in the world coordinate system.

Interactive users frequently use C-Space for their drawing activities.  E-Space is a local coordinate system that is  stored with each entity.  When an entity is created, the E-Space of the entity is initialized to the C-Space that is current at the time that the entity is created.  When an entity is rotated or moved, the E-Space of the entity is also rotated or moved along with the entity.

There are a number of commands that can be used to define a C-Space.  Two of these commands are illustrated below.  The first command defines the C-Space according to an origin point and the direction of the x and y axes.  The second command aligns the C-Space to the E-Space of a object with the name \room2\wall2.

 C / C++ Code ss_command (“c-space align axes %z %z %z”,&origin,&xaxis,&yaxis);  ss_command (“c-space align e-space object \\room2\\wall2”);

In application programs, it is very useful to be able to execute SilverScreen commands relative to C-Space.  The following two commands draw lines in W-Space.

 C / C++ Code SS_XYZ p, q;  ...  ss_command ( "draw line 2,3,4 1,1,5" );  ss_command ( "draw line %z %z”, &p, &q );

By enclosing the coordinates by square brackets, the points are interpreted to be C-Space points.  The first command below will draw a line between C-Space points 2,3,4 and 1,1,5.  This is shown below.

 C / C++ Code SS_XYZ p, q;  ...  ss_command ( "draw line [2,3,4] [1,1,5]" );  ss_command ( "draw line [%z] [%z]”, &p, &q );

# An Example

The function draw_frame, shown below, draws a frame in C-Space.  The frame will be of height h and width w, and will consist of four solid members.  The members will be of thickness t and depth d..  Here is a front view of the frame: The orientation of the frame is determined by the parameters origin, xaxis, and yaxis.  The lower left corner of the frame will be constructed at origin.  The frame will extend to the right in the direction of xaxis, and will extend upward in the direction of the yaxis.

The draw_frame function begins by aligning the C-Space to the parameters origin, xaxis, and yaxis.  Four polygons are then drawn within the object temp.  Note that the function draw_polygon draws these points in C-Space.  The solids are then created by sweeping all four polygons in a single operation.  The direction and depth of the sweep is determined by the C-Space points [0,0,0] and [0,0,d].  This specifies a sweep of distance d along the z-axis of the C-Space.

 C / C++ Code void draw_frame(double h, double w, double t, double d,                XYZ *origin, XYZ *xaxis, XYZ *yaxis)  {  XYZ ll,ul,lr,ur;    ss_command (“c-space align axes %z %z %z”,origin,xaxis,yaxis);  ss_command (“create object temp”);    ll.z = ul.z = lr.z = ur.z = 0.0;  // Draw the lower member  ll.x = ul.x = 0.0;  lr.x = ur.x = w;  ll.y = lr.y = 0.0;  ul.y = ur.y = t;  draw_polygon (&ll,&lr,&ur,&ul);      // Draw the left member  ll.x = ul.x = 0.0;  lr.x = ur.x = t;  ll.y = lr.y = t;  ul.y = ur.y = h-t;  draw_polygon (&ll,&lr,&ur,&ul);      // Draw the right member  ll.x = ul.x = w-t;  lr.x = ur.x = w;  ll.y = lr.y = t;  ul.y = ur.y = h-t;  draw_polygon (&ll,&lr,&ur,&ul);      // Draw the upper member  ll.x = ul.x = 0.0;  lr.x = ur.x = w;  ll.y = lr.y = h-t;  ul.y = ur.y = h;  draw_polygon (&ll,&lr,&ur,&ul);      ss_command (“sweep linear object \\temp points [0,0,0] [0,0,%f]              color white fill-color yellow name frame1”, t);  }    void draw_polygon (XYZ *p1, XYZ *p2, XYZ *p2, XYZ *p4)  {  ss_command (“begin polygon”);  ss_command(“point [%z]”,p1);  ss_command(“point [%z]”,p2);  ss_command(“point [%z]”,p3);  ss_command(“point [%z]”,p4);  ss_command(“end”);  }