Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# Math::Zap::Triangle 1.07

Date Added: January 03, 2010  |  Visits: 757

Math::Zap::Triangle module can build triangles in 3D space. Synopsis Example t/triangle.t #_ Triangle ___________________________________________________________ # Test 3d triangles # philiprbrenan@yahoo.com, 2004, Perl License #______________________________________________________________________ use Math::Zap::Vector; use Math::Zap::Vector2; use Math::Zap::Triangle; use Test::Simple tests=>25; \$t = triangle (vector( 0, 0, 0), vector( 0, 0, 4), vector( 4, 0, 0), ); \$u = triangle (vector( 0, 0, 0), vector( 0, 1, 4), vector( 4, 1, 0), ); \$T = triangle (vector( 0, 1, 0), vector( 0, 1, 1), vector( 1, 1, 0), ); \$c = vector(1, 1, 1); #_ Triangle ___________________________________________________________ # Distance to plane #______________________________________________________________________ ok(\$t->distance(\$c) == 1, Distance to plane); ok(\$T->distance(\$c) == 0, Distance to plane); ok(\$t->distance(2*\$c) == 2, Distance to plane); ok(\$t->distanceToPlaneAlongLine(vector(0,-1,0), vector(0,1,0)) == 1, Distance to plane towards a point); ok(\$T->distanceToPlaneAlongLine(vector(0,-1,0), vector(0,1,0)) == 2, Distance to plane towards a point); #_ Triangle ___________________________________________________________ # Permute the points of a triangle #______________________________________________________________________ ok(\$t->permute == \$t, Permute 1); ok(\$t->permute->permute == \$t, Permute 2); ok(\$t->permute->permute->permute == \$t, Permute 3); #_ Triangle ___________________________________________________________ # Intersection of a line with a plane defined by a triangle #______________________________________________________________________ #ok(\$t->intersection(\$c, vector(1, -1, 1)) == vector(1, 0, 1), Intersection of line with plane); #ok(\$t->intersection(\$c, vector(-1, -1, -1)) == vector(0, 0, 0), Intersection of line with plane); #_ Triangle ___________________________________________________________ # Test whether a point is in front or behind a plane relative to another # point #______________________________________________________________________ ok(\$t->frontInBehind(\$c, vector(1, 0.5, 1)) == +1, Front); ok(\$t->frontInBehind(\$c, vector(1, 0, 1)) == 0, In); ok(\$t->frontInBehind(\$c, vector(1, -0.5, 1)) == -1, Behind); #_ Triangle ___________________________________________________________ # Parallel #______________________________________________________________________ ok(\$t->parallel(\$T) == 1, Parallel); ok(\$t->parallel(\$u) == 0, Not Parallel); #_ Triangle ___________________________________________________________ # Coplanar #______________________________________________________________________ #ok(\$t->coplanar(\$t) == 1, Coplanar); #ok(\$t->coplanar(\$u) == 0, Not coplanar); #ok(\$t->coplanar(\$T) == 0, Not coplanar); #_ Triangle ___________________________________________________________ # Project one triangle onto another #______________________________________________________________________ \$p = vector(0, 2, 0); \$s = \$t->project(\$T, \$p); ok(\$s == triangle (vector(0, 0, 2), vector(0.5, 0, 2), vector(0, 0.5, 2), ), Projection of corner 3); #_ Triangle ___________________________________________________________ # Convert space to plane coordinates and vice versa #______________________________________________________________________ ok(\$t->convertSpaceToPlane(vector(2, 2, 2)) == vector(0.5,0.5,2), Space to Plane); ok(\$t->convertPlaneToSpace(vector2(0.5, 0.5)) == vector(2, 0, 2), Plane to Space); #_ Triangle ___________________________________________________________ # Divide #______________________________________________________________________ \$it = triangle # Intersects t (vector( 0, -1, 2), vector( 0, 2, 2), vector( 3, 2, 2), ); @d = \$t->divide(\$it); ok(\$d[0] == triangle(vector(0, -1, 2), vector(0, 0, 2), vector(1, 0, 2))); ok(\$d[1] == triangle(vector(0, 2, 2), vector(0, 0, 2), vector(1, 0, 2))); ok(\$d[2] == triangle(vector(0, 2, 2), vector(1, 0, 2), vector(3, 2, 2))); \$it = triangle # Intersects t (vector( 3, 2, 2), vector( 0, 2, 2), vector( 0, -1, 2), ); @d = \$t->divide(\$it); ok(\$d[0] == triangle(vector(0, -1, 2), vector(0, 0, 2), vector(1, 0, 2))); ok(\$d[1] == triangle(vector(3, 2, 2), vector(1, 0, 2), vector(0, 0, 2))); ok(\$d[2] == triangle(vector(3, 2, 2), vector(0, 0, 2), vector(0, 2, 2))); \$it = triangle # Intersects t (vector( 3, 2, 2), vector( 0, -1, 2), vector( 0, 2, 2), ); @d = \$t->divide(\$it); ok(\$d[0] == triangle(vector(0, -1, 2), vector(1, 0, 2), vector(0, 0, 2))); ok(\$d[1] == triangle(vector(3, 2, 2), vector(1, 0, 2), vector(0, 0, 2))); ok(\$d[2] == triangle(vector(3, 2, 2), vector(0, 0, 2), vector(0, 2, 2)));.

 Requirements: No special requirements Platforms: Linux Keyword: Libraries,  Mathzaptriangle,  Plane,  Programming,  Triangle,  Vector Users rating: 0/10

 License: Freeware Size: 63.49 KB
USER REVIEWS
 More Reviews or Write Review
MATH::ZAP::TRIANGLE RELATED
 Programming  -  devkitPro 1.5.7 This project is for homebrew console development tools based on the gnu compiler collection with additional tools and libraries to aid programming each supported console. The windows variants are built with MinGW. 444.26 KB Libraries  -  GODI 20060118 GODI library provides an advanced programming environment for the Objective Caml (OCaml) language. From INRIA (who created OCaml) you can get the OCaml compiler and runtime system, but this is usually not enough to develop applications. You also... 1.5 MB Multimedia & Graphics  -  Asymptote for Mac OS X 2.15 Asymptote is a powerful descriptive vector graphics language that provides a natural coordinate-based framework for technical drawing. Labels and equations are typeset with LaTeX, for high-quality PostScript output.Asymptote is a graphic tool that... 3.7 MB Development Tools  -  Minimum Perfect Matching Tool 1.0 Function to solve the Minimum Perfect Matching on non-biparite graphs problem using Integer linear programming.Returns vector of matched indices and cost of the match. Requires symmetric adjacent matrix of even rank. function [ indices, cost ] =... 10 KB Network & Internet  -  Simpy Tools 1.1 SimpyTools is a collection of various software for using and enhancing the simpy.com social bookmarking service. Simpy Tools includes libraries in various programming languages for using the REST API of simpy.com. It also includes a Firefox... 17.41 KB Programming  -  Robot Framework 2.5.7 Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). It has easy-to-use tabular test data syntax and utilizes the keyword-driven testing approach. Its testing capabilities can... 1.64 MB Libraries  -  SVL 1.5 SVL library provides vector and matrix classes, as well as a number of functions for performing vector arithmetic with them. Equation-like syntax is supported via class operators, for example: #include "svl/SVL.h" Vec3 v(1.0, 2.0, 3.0); Mat3... 112.64 KB Libraries  -  Vector Visuals 2006.12.02 Vector Visuals provides an easy-to-use, object-based API for creating and manipulating Java2D-rendered shapes and images. The project features object embedding, dynamic connectors, and multithreaded task support. Vector Visuals has been... 39.94 KB Libraries  -  Adobe Source Libraries 1.0.29 The Adobe Source Libraries (ASL) are a collection of C++ libraries building foundation technology to allow the construction of commercial applications by assembling generic algorithms through declarative descriptions. Whats New in This Release:... 8.2 MB Libraries  -  GNU Classpath 0.95 GNU Classpath (essential libraries for Java) is a project to create free core class libraries for use with virtual machines and compilers for the Java programming language. GNU Classpath project includes all native methods and core classes... 6.5 MB