@ 2014-05-28T13:57:11Z <?php
class Point {
public $X;
public $Y;
function __construct($X, $Y)
{
$this->X = $X;
$this->Y = $Y;
}
}
$moves = 4;
$mouseX = 0;
$mouseY = 0;
$point = new Point(400, 400);
//$startAngle = rand(0, 90);
$startAngle = 30;
echo 'Angle = '.$startAngle."\r\n";
$angles = array($startAngle);
for ( $i=1; $i<$moves; $i++ ) {
$angles[$i] = $angles[$i-1] + (90 - 2*$startAngle)/($moves-1);
}
$lineHeightDiv = 0;
foreach ( $angles as $angle ) {
$lineHeightDiv += sin($angle*pi()/180);
}
$lineHeight = ($point->Y-$mouseY)/$lineHeightDiv;
echo 'LineHeight = '.$lineHeight."\r\n";
$lineWidthDiv = 0;
foreach ( $angles as $angle ) {
$lineWidthDiv += cos($angle*pi()/180);
}
$lineWidth = ($point->X-$mouseX)/$lineWidthDiv;
echo 'LineWidth = '.$lineWidth."\r\n";
$points = array(new Point($mouseX, $mouseY));
for ( $i=1; $i<=$moves; $i++ ) {
$x = $points[$i-1]->X + $lineWidth*cos($angles[$i]*pi()/180);
$y = $points[$i-1]->Y + $lineHeight*sin($angles[$i]*pi()/180);
$points[] = new Point($x, $y);
}
var_dump($points);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Angle = 30
LineHeight = 144.15154877597
LineWidth = 144.15154877597
Warning: Undefined array key 4 in /in/4Na6j on line 47
Warning: Undefined array key 4 in /in/4Na6j on line 48
array(5) {
[0]=>
object(Point)#2 (2) {
["X"]=>
int(0)
["Y"]=>
int(0)
}
[1]=>
object(Point)#3 (2) {
["X"]=>
float(110.42649290682859)
["Y"]=>
float(92.65882947032038)
}
[2]=>
object(Point)#4 (2) {
["X"]=>
float(203.085322377149)
["Y"]=>
float(203.08532237714897)
}
[3]=>
object(Point)#5 (2) {
["X"]=>
float(275.1610967651356)
["Y"]=>
float(327.92422561201334)
}
[4]=>
object(Point)#6 (2) {
["X"]=>
float(419.3126455411088)
["Y"]=>
float(327.92422561201334)
}
}
Output for 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.25 , 7.4.27 - 7.4.33 Angle = 30
LineHeight = 144.15154877597
LineWidth = 144.15154877597
Notice: Undefined offset: 4 in /in/4Na6j on line 47
Notice: Undefined offset: 4 in /in/4Na6j on line 48
array(5) {
[0]=>
object(Point)#2 (2) {
["X"]=>
int(0)
["Y"]=>
int(0)
}
[1]=>
object(Point)#3 (2) {
["X"]=>
float(110.42649290683)
["Y"]=>
float(92.65882947032)
}
[2]=>
object(Point)#4 (2) {
["X"]=>
float(203.08532237715)
["Y"]=>
float(203.08532237715)
}
[3]=>
object(Point)#5 (2) {
["X"]=>
float(275.16109676514)
["Y"]=>
float(327.92422561201)
}
[4]=>
object(Point)#6 (2) {
["X"]=>
float(419.31264554111)
["Y"]=>
float(327.92422561201)
}
}
Output for 7.3.32 - 7.3.33 , 7.4.26 Angle = 30
LineHeight = 144.15154877597
LineWidth = 144.15154877597
array(5) {
[0]=>
object(Point)#2 (2) {
["X"]=>
int(0)
["Y"]=>
int(0)
}
[1]=>
object(Point)#3 (2) {
["X"]=>
float(110.42649290683)
["Y"]=>
float(92.65882947032)
}
[2]=>
object(Point)#4 (2) {
["X"]=>
float(203.08532237715)
["Y"]=>
float(203.08532237715)
}
[3]=>
object(Point)#5 (2) {
["X"]=>
float(275.16109676514)
["Y"]=>
float(327.92422561201)
}
[4]=>
object(Point)#6 (2) {
["X"]=>
float(419.31264554111)
["Y"]=>
float(327.92422561201)
}
}
Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 Angle = 30
LineHeight = 144.15154877597
LineWidth = 144.15154877597
Notice: Undefined offset: 4 in /in/4Na6j on line 47
Notice: Undefined offset: 4 in /in/4Na6j on line 48
array(5) {
[0]=>
object(Point)#2 (2) {
["X"]=>
int(0)
["Y"]=>
int(0)
}
[1]=>
object(Point)#3 (2) {
["X"]=>
float(110.42649290683)
["Y"]=>
float(92.65882947032)
}
[2]=>
object(Point)#4 (2) {
["X"]=>
float(203.08532237715)
["Y"]=>
float(203.08532237715)
}
[3]=>
object(Point)#5 (2) {
["X"]=>
float(275.16109676514)
["Y"]=>
float(327.92422561201)
}
[4]=>
object(Point)#6 (2) {
["X"]=>
float(419.31264554111)
["Y"]=>
float(327.92422561201)
}
}
Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/4Na6j on line 4
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/4Na6j on line 4
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/4Na6j on line 4
Process exited with code 255 . preferences:dark mode live preview
325.18 ms | 401 KiB | 460 Q