Author: Laurence D. Finston.
This copyright notice applies to the text and source code of this web site, and the graphics that appear on it. The software described in this text has its own copyright notice and license, which can be found in the distribution itself.
Copyright (C) 2005, 2006, 2007 The Free Software Foundation
Permission is granted to copy, distribute, and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of this license is included in the file COPYING.TXT
Last updated: April 29, 2006
|Classifying Points with Respect to a Cuboid|
The type cuboid in the 3DLDF language corresponds to class Cuboid in the C++ code. class Cuboid is defined in the file cuboid.web. class Cuboid already existed in Release 188.8.131.52, so it's documented in the manual. This web page contains examples and illustrations of newer features.
points can be classified according to their position with respect to a cuboid by using the location operator:
cuboid c; c := unit_cuboid scaled (20, 16, 10) rotated (-20, 15); draw c; point p; p0 := (0, 1, 1); message "p0 location c:"; show p0 location c; rectangle r; r0 := get_rectangle 0 c; p1 := mediate(get_point 0 r0, get_point 3 r0, 1/3); message "p1 location c:"; show p1 location c; r1 := get_rectangle 4 c; p2 := mediate(get_point 0 r1, get_point 2 r1) shifted (0, 2); message "p2 location c:"; show p2 location c; end;
location returns one of the following numerical values:
|0:||The point lies on the surface of the cuboid.|
|1:||The point lies within the cuboid.|
|-1:||The point lies outside the cuboid.|
|INVALID_NUMERIC:||An error occurred.|
In the following image, p0 lies inside the cuboid, p1 on one of its edges, p2 on one of its faces, and p3 outside of it. The complete 3DLDF code for generating this image can be found in cubd_01.ldf.
The following four images illustrate the intersections of a cuboid and a linear path. The 3DLDF code for generating these images is in cubd_02.ldf.
Parallel Projection, X-Z Plane
Parallel Projection, X-Y Plane
Parallel Projection, Z-Y Plane
The following four images illustrate the intersection of a cuboid and a plane, which, in general, is a polygon. It could also be a point, but I haven't accounted for this case yet. The 3DLDF code for generating these images is in cubd_06.ldf.
Parallel Projection, X-Z Plane (scaled 3/4 size)
Parallel Projection, X-Y Plane (scaled 3/4 size)
Parallel Projection, Z-Y Plane (scaled 3/4 size)