Changeset 95 for trunk/Point.php


Ignore:
Timestamp:
Dec 6, 2021, 11:33:48 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
  • Added: Explicit types for better type checking.
  • Fixed: Support for php 8.0.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Point.php

    r92 r95  
    33class Point
    44{
    5   var $X;
    6   var $Y;
     5  public int $X;
     6  public int $Y;
    77
    8   function __construct($X, $Y)
     8  function __construct(int $X, int $Y)
    99  {
    1010    $this->X = $X;
     
    1313}
    1414
    15 function NewPoint($X, $Y)
     15function NewPoint(int $X, int $Y): Point
    1616{
    1717  $Point = new Point($X, $Y);
     
    2020
    2121/* Linear interpolation between two points */
    22 function Interpolation(Point $P1, Point $P2, $X)
     22function Interpolation(Point $P1, Point $P2, $X): float
    2323{
    2424  $Y = ($P2->Y - $P1->Y) / ($P2->X - $P1->X) * ($X - $P1->X) + $P1->Y;
Note: See TracChangeset for help on using the changeset viewer.