Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 130 | | All time: 9,362 This week: 55 |
Version | | License | | PHP version | | Categories |
model-3d-class 1.0 | | Custom (specified... | | 5 | | PHP 5, Graphics, Physics |
|
Description | | Author |
This class can render a 3D object from the shapes definitions
It takes a list of nodes of the edges and lines of the model of a 3D object and renders an image that shows the lines and the edges of the described object. The class can also add lines for the ground plane.
The the rendered image of the 3D model object is stored in a class variable that is set to a image object created by the PHP GD extension. | |
|
|
Innovation award
Nominee: 3x |
|
Example
<?php
include("model3d.php");
$model3d = new Model3D();
$model3d->drawGridXY(80, 80);
gen($model3d);
$model3d->drawOrigin();
header("Content-type: image/png");
imagepng($model3d->canvas);
imagedestroy($imgcanvas->canvas);
function gen($model)
{
// generate nodes and lines for a truss3d
$node = array();
$line = array();
$n = 4; // no of in-scribed polygon sides
$m = 2; // no of storey
$dh =200; // height of each storey
$r = 120; // radius of polygon
$dr = -20; // reduce radius per storey
$dang = 360/$n;
$startang = $dang/2;
for ($j=0;$j<$m+1;$j++){
for($i=0;$i<$n;$i++){
$ang = $startang+$i*$dang;
$ang = $ang/180.0*pi();
$x = ($r+$dr*$j)*cos($ang);
$y = ($r+$dr*$j)*sin($ang);
$z = $j*$dh;
$node[] = array(
"x" => $x,
"y" => $y,
"z" => $z,
"dof" => "000",
"dx" => 0.00,
"dy" => 0.00,
"dz" => 0.0
);
$i1 = ($i+$n*$j)%$n;
$j1 = ($i+$n*$j+1)%$n;
if ($j < $m){
$line[] = array(
"I" => $n*($j+1)+$i1,
"J" => $n*($j+1)+$j1,
"Mat" => 0,
"Sec" => 0
);
$line[] = array(
"I" => $n*$j+$i1,
"J" => $n*($j+1)+$i1,
"Mat" => 0,
"Sec" => 0
);
$line[] = array(
"I" => $n*$j+$i1,
"J" => $n*($j+1)+$j1,
"Mat" => 0,
"Sec" => 0
);
}
}
}
$model->drawNodesLine($node, $line);
}
?>
|
Details
PHP-Model3D-Class
3dimensional perspective drawing class
##Model3DClass
* [Model3D] class create 3 dimensional perspective view by projecting 3d coordinate system onto 2d canvas.
* Current model provide 2 modes, z axis vertical and y axis vertical.
* This simplest first version implement only 3 dimensional line drawing and wire frame that include 3d nodes and connected lines.
* 3D object is centeted at PROJECTION_CENTER center point on the canvas view. View rotation is defined with $ROT about vertical axis.
* Coordinate system obey right-hand-rule.
##Sample
1. Drawtower1.php is a sample file that use Model3D class and create 3d trustal tower.
2. index.php is a sample for the html file.
##Permission
* This class is free for the educational use as long as maintain this header together with this class. Contact author for other uses.
* Author: Win Aung Cho
* Contact winaungcho@gmail.com
* version 1.0
* Date: 4-11-2020
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.