Exemple #1
0
function Dist($xA, $yA, $xB, $yB, $xP, $yP)
{
    $result = Area($xA, $yA, $xB, $yB, $xP, $yP);
    $area = $result['triangle_area'];
    $a = $result['data_about_triangle']['length']['a'];
    $distance = 2 * $area / $a;
    return $distance;
}
Exemple #2
0
function areaN($p)
{
    $totalArea = 0;
    for ($i = 1; $i < sizeof($p) - 1; $i++) {
        $triangle = new TTriangle($p[0]->getX(), $p[0]->getY(), $p[$i]->getX(), $p[$i]->getY(), $p[$i + 1]->getX(), $p[$i + 1]->getY());
        $totalArea += Area($triangle);
    }
    return $totalArea;
}
Exemple #3
0
<head>
    <title>58</title>
</head>
<?php 
/**
 * Using the Leng and Perim functions from the tasks Proc56 and Proc57,
 * write a real-valued function Area(xA, yA, xB, yB, xC, yC) that returns the area of a triangle ABC:
 * SABC = (p·(p−|AB|)·(p−|AC|)·(p−|BC|))1/2,
 * where p is the half-perimeter. Using the Area function, find the areas of
 * triangles ABC, ABD, ACD provided that coordinates of points A, B, C, D are given.
 */
echo '<div style="display: none">';
include '57.php';
echo '</div>';
function Area($xA, $yA, $xB, $yB, $xC, $yC)
{
    $result = allLength($xA, $yA, $xB, $yB, $xC, $yC);
    $term1 = abs($result['perimeter'] - $result['length']['a']);
    $term2 = abs($result['perimeter'] - $result['length']['b']);
    $term3 = abs($result['perimeter'] - $result['length']['c']);
    $underRootExpression = $result['perimeter'] * $term1 * $term2 * $term3;
    $area = pow($underRootExpression, 1 / 2);
    $area = number_format($area, 3, '.', ' ');
    $response = array('data_about_triangle' => $result, 'triangle_area' => $area);
    return $response;
}
$area1 = Area(2, 2, 2, 6, 6, 2);
$area2 = Area(0, 0, 0, 1, 1, 0);
echo $area1['triangle_area'] . '<br/>';
echo $area2['triangle_area'] . '<br/>';
<?php

include 'algoritmo.php';
$_GET['id'] = "A01129415";
if (isset($_GET['id'])) {
    $area = Area($_GET['id'], "alumno");
    $area['ocupados'] = ocupados($area['area']);
    $area['asignados'] = asignados($area['area']);
    $cajon = $area['recomendado']['idcajonEstacionamiento'];
    if (isset($area['recomendado']['idcajonEstacionamiento'])) {
        Query('update cajonEstacionamiento set status = "asignado" where idcajonEstacionamiento = ' . $cajon);
        $insert = 'insert into asignacionCajon (horaAsignacion,tiempoTolerancia,horaFinAsignacion,idCajonEstacionamiento,idUsuario) values (now(),15,now() + interval 15 minute,' . $cajon . ',"' . $_GET['id'] . '")';
        Query($insert);
    }
    /*
    echo "<pre>";
    print_r($area);
    echo "</pre>";
    */
    echo json_encode($area);
    Query("update cajonEstacionamiento set status = 'disponible' where status = 'asignado';");
}
Exemple #5
0
<?php

/**
 * Using the TPoint and TTriangle types and the Dist function (see Param64, Param65, Param67), write a procedure Alts
 * (T, h1, h2, h3) that evaluates the altitudes h1, h2, h3 drawn from the vertices T.A, T.B, T.C of a triangle T (T is
 * an input parameter of TTriangle type, h1, h2, h3 are output real-valued parameters). Using this procedure, evaluate
 * the altitudes of each of triangles ABC, ABD, ACD provided that the coordinates of points A, B, C, D are given.
 */
echo '<div style="display: none;">';
//
include 'helper.php';
include '67.php';
require_once '66.php';
require_once '64.php';
echo '</div >';
use TPoint\TPoint;
use ParamPhpJavaScrit\TTriangle\TTriangle;
$t1 = new TTriangle(2, 6, 7, 1, 2, 1);
$s = Area($t1);
$a = new TPoint($t1->getAx(), $t1->getAy());
$b = new TPoint($t1->getBx(), $t1->getBy());
$c = new TPoint($t1->getCx(), $t1->getCy());
$length1 = Leng2($a, $b);
$length2 = Leng2($a, $c);
$length3 = Leng2($b, $c);
echo Dist($s, $length1) . '<br/>';
echo Dist($s, $length2) . '<br/>';
echo Dist($s, $length3) . '<br/>';
Exemple #6
0
 * where p is the half-perimeter. Using this function, find the areas of triangles ABC, ABD, ACD provided that the
 * coordinates of points A, B, C, D are given.
 */
echo '<div style="display: none;">';
include 'helper.php';
include '64.php';
require_once '65.php';
echo '</div >';
use TPoint\TPoint;
use ParamPhpJavaScrit\TTriangle\TTriangle;
function Leng1($a, $b)
{
    $length = pow($a->getX() - $b->getX(), 2) + pow($a->getY() - $b->getY(), 2);
    $len = sqrt($length);
    return $len;
}
function Area($T)
{
    $a = new TPoint($T->getAx(), $T->getAy());
    $b = new TPoint($T->getBx(), $T->getBy());
    $c = new TPoint($T->getCx(), $T->getCy());
    $l1 = Leng1($a, $b);
    $l2 = Leng1($b, $c);
    $l3 = Leng1($c, $a);
    $p = $l1 + $l2 + $l3;
    //SABC = (p·(p − |AB|)·(p − |AC|)·(p − |BC|))1/2,
    return sqrt($p * ($p - $l1) * ($p - $l2) * ($p - $l3));
}
$t1 = new TTriangle(2, 6, 7, 1, 2, 1);
echo Area($t1);