DMM Varkon® Tutorial
A Beginner's Guide to the Varkon Parametric Modeling and CAD Application Development System
By David M. MacMillan


5.2. Establishing a Local Coordinate System

Local coordinate systems may be created within the current global coordinate system. To add a local coordinate system to the model above:

BASIC GEOMETRY MODULE test3d();
BEGINMODULE
part(#1,vclb(15, 0, 1));
part(#2,box1q(8, 2, 4));
neworigin1:=vec(0, 10, 0);
csys_1p(#3,"lcs1", neworigin1, 0, 0, 0);
ENDMODULE

This adds a new coordinate system whose origin is at (0, 10, 0) within the existing global coordinate system. This new system is named "lcs1" (local coordinate system 1). It could have been rotated around any of the three axes of the global system, but in this case it is not. Coordinate systems are entities just as geometric constructions are, so they are given identity numbers ("#3" here). This new coordinate system is shown by three black arrows:

lcs1

This only defines the coordinate system; as yet, nothing actually uses it. Were we to draw a figure just after this definition, such a figure would be drawn using the preexisting coordinate system (in this case the global coordinate system for the model). In order to draw in a particular local coordinate system, we must make that system active. This is done by adding the "mode_local()" statement to the active module. As any number of local coordinate systems might be defined, it is necessary to tell mode_local() the identity ("#3") of the coordinate system we wish to use.

BASIC GEOMETRY MODULE test3d();
BEGINMODULE
part(#1,vclb(15, 0, 1));
part(#2,box1q(8, 2, 4));
neworigin1:=vec(0, 10, 0);
csys_1p(#3,"lcs1", neworigin1, 0, 0, 0);
mode_local(#3);
ENDMODULE

The lcs1 coordinate system is now shown as active by means of a larger set of arrows:

lcs1

In this newly active local coordinate system, we can now draw, for example, a line.

BASIC GEOMETRY MODULE test3d();
BEGINMODULE
part(#1,vclb(15, 0, 1));
part(#2,box1q(8, 2, 4));
neworigin1:=vec(0, 10, 0);
csys_1p(#3,"lcs1", neworigin1, 0, 0, 0);
mode_local(#3); lin_free(#5,vec(0, 0, 0), vec(5, 5, 0):WIDTH=0.2,PEN=5);
ENDMODULE

lcs1

However, if we try to call a GLOBAL module such as box1q, we find that it still draws within the model's global coordinate system.

BASIC GEOMETRY MODULE test3d();
BEGINMODULE
part(#1,vclb(15, 0, 1));
part(#2,box1q(8, 2, 4));
neworigin1:=vec(0, 10, 0);
csys_1p(#3,"lcs1", neworigin1, 0, 0, 0);
mode_local(#3); lin_free(#5,vec(0, 0, 0), vec(5, 5, 0):WIDTH=0.2,PEN=5);
part(#6,box1q(3, 3, 3));
ENDMODULE

lcs1

In order to instantiate a module within the local coordinate system, it is necessary to use a module with the LOCAL attribute and to specify in its calling which coordinate system it is local to. The MBS module boxnorot() below is a LOCAL module which draws a box of some size (dx, dy, dz) at some offset (xoffset, yoffset, zoffset) within a specified local coordinate system. It performs no rotations on the box, however, it may be called within a rotated coordinate system.

! boxnorot.MBS
!
! Draw a rectilinear (unrotated) box
!
! Use the same coloring for the lines defining the box as is used for
! demonstration axes in vcl.MBS:
! X = red, Y = green, Z = blue (RGB == XYZ)
!

local geometry module boxnorot(
float dx;
float dy;
float dz;
float xoffset;
float yoffset;
float zoffset
);

vector lbb; ! left back bottom; origin
vector lbt; ! left back top
vector lft; ! left front top
vector lfb; ! left front bottom

vector rbb; ! right back bottom
vector rbt; ! right back top
vector rft; ! right front top
vector rfb; ! right front bottom

beginmodule

lbb := vec (0 + xoffset, 0 + yoffset, 0 +zoffset);
lbt := vec (0 + xoffset, dy + yoffset, 0 +zoffset);
lft := vec (0 + xoffset, dy + yoffset, dz +zoffset);
lfb := vec (0 + xoffset, 0 + yoffset, dz +zoffset);

lin_free (#1, lfb, lbb: PEN=4);
lin_free (#2, lft, lbt: PEN=4);
lin_free (#3, lfb, lft: PEN=3);
lin_free (#4, lbb, lbt: PEN=3);

rbb := vec (dx + xoffset, 0 + yoffset, 0 +zoffset);
rbt := vec (dx + xoffset, dy + yoffset, 0 +zoffset);
rft := vec (dx + xoffset, dy + yoffset, dz +zoffset);
rfb := vec (dx + xoffset, 0 + yoffset, dz +zoffset);

lin_free (#5, rfb, rbb: PEN=4);
lin_free (#6, rft, rbt: PEN=4);
lin_free (#7, rfb, rft: PEN=3);
lin_free (#8, rbb, rbt: PEN=3);

lin_free (#9, lbb, rbb: PEN=2);
lin_free (#10, lfb, rfb: PEN=2);

lin_free (#11, lbt, rbt: PEN=2);
lin_free (#12, lft, rft: PEN=2);

endmodule

To invoke this box in the "lcs1" (#3) local coordinate system, change the active module as described below. Note that since the boxnorot part instantiation specifies the lcs1 coordinate system explicitly, it is not necessary to call mode_local(#3). However, without this call to mode_local(), ordinary (non part call-to-module) drawing still takes place within the preexisting global coordinate system.

BASIC GEOMETRY MODULE test3d();
BEGINMODULE
part(#1,vclb(15, 0, 1));
part(#2,box1q(8, 2, 4));
neworigin1:=vec(0, 10, 0);
csys_1p(#3,"lcs1", neworigin1, 0, 0, 0);
part(#4,boxnorot(8, 2, 4, 0, 0, 0),#3);
ENDMODULE

lcs1

To see that this box is drawn relative to the local coordinate system lcs1 regardless of the orientation of that coordinate system, consider the following example where lcs1 has been rotated 30 degrees counterclockwise (viewed from above) around the Y axis.

BASIC GEOMETRY MODULE test3d();
BEGINMODULE
part(#1,vclb(15, 0, 1));
part(#2,box1q(8, 2, 4));
neworigin1:=vec(0, 10, 0);
csys_1p(#3,"lcs1", neworigin1, 0, 30, 0);
part(#4,boxnorot(8, 2, 4, 0, 0, 0),#3);
ENDMODULE

This appears as:

lcs1


Legal Matters

With the exception of any material noted as being in the public domain, the text, images, and encoding of this document are copyright © 1998 by David M. MacMillan.

The author has no relationship with Microform AB, and this Tutorial is neither a product of nor endorsed by Microform AB.

"Varkon" is a registered trademark of Microform AB, Sweden.

This document is licensed for private, noncommercial, nonprofit viewing by individuals on the World Wide Web. Any other use or copying, including but not limited to republication in printed or electronic media, modification or the creation of derivative works, and any use for profit, is prohibited.

This writing is distributed in the hope that it will be useful, but "as-is," without any warranty of any kind, expressed or implied; without even the implied warranty of merchantability or fitness for a particular purpose.

In no event will the author(s) or editor(s) of this document be liable to you or to any other party for damages, including any general, special, incidental or consequential damages arising out of your use of or inability to use this document or the information contained in it, even if you have been advised of the possibility of such damages.

In no event will the author(s) or editor(s) of this document be liable to you or to any other party for any injury, death, disfigurement, or other personal damage arising out of your use of or inability to use this document or the information contained in it, even if you have been advised of the possibility of such injury, death, disfigurement, or other personal damage.

All trademarks or registered trademarks used in this document are the properties of their respective owners and (with the possible exception of any marks owned by the author(s) or editor(s) of this document) are used here for purposes of identification only. A trademark catalog page lists the marks known to be used on these web pages. Please e-mail dmm@lemur.com if you believe that the recognition of a trademark has been overlooked.


Version 1.3, 1998/06/17. Feedback to dmm@lemur.com
http://www.database.com/~lemur/vk-coordlocal.html


Go to the: