The GNU 3DLDF Cuboids Page

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 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


Table of Contents

Top
Introduction
Classifying Points with Respect to a Cuboid
Intersections
Cuboid–Linear Path
Cuboid–Plane
Contact

Back to top
Back to Polyhedra page
Back to main contents
Back to main page

Introduction

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 1.1.5.1, so it's documented in the manual. This web page contains examples and illustrations of newer features.


Back to contents
Back to top
Back to Polyhedra page
Back to main contents
Back to main page

Classifying Points with Respect to a Cuboid

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.




[Cuboid 1]


Back to contents
Back to top
Back to Polyhedra page
Back to main contents
Back to main page

Intersections

The Intersection Points of a Cuboid and a Linear Path

2005.12.16.
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.



[Cuboid-Linear Path Intersection 1]

Perspective Projection




[Cuboid-Linear Path Intersection 2]

Parallel Projection, X-Z Plane




[Cuboid-Linear Path Intersection 3]

Parallel Projection, X-Y Plane




[Cuboid-Linear Path Intersection 4]

Parallel Projection, Z-Y Plane


Back to contents
Back to top
Back to Polyhedra page
Back to main contents
Back to main page

The Intersection of a Cuboid and a Plane

2005.12.16.
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.



[Cuboid-Plane Intersection 1]

Perspective Projection




[Cuboid-Plane Intersection 2]

Parallel Projection, X-Z Plane (scaled 3/4 size)




[Cuboid-Plane Intersection 3]

Parallel Projection, X-Y Plane (scaled 3/4 size)




[Cuboid-Plane Intersection 4]

Parallel Projection, Z-Y Plane (scaled 3/4 size)


Back to contents
Back to top
Back to Polyhedra page
Back to main contents
Back to main page