Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <title>Point in a Circle</title>
- <meta charset="UTF-8"/>
- </head>
- <body>
- <h3>Координатите в кръг с координати (0,0) и радиус 2 ли са?</h3>
- <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="get">
- X <input type="text" name="user_x" size="10">
- Y <input type="text" name="user_y" size="10"><br/>
- <input type="submit" name="send" value="OK"><br/>
- <form>
- <?php
- if(isset($_GET['send'])){
- $user_x = $_GET['user_x'];
- $user_y = $_GET['user_y'];
- $cir_x = 0;
- $cir_y = 0;
- $cir_r = 2;
- if(is_numeric($user_x) && is_numeric($user_y)){
- $check = pow(($user_x-$cir_x),2) + pow(($user_y-$cir_y),2);
- //radius r and center (h,k)
- //The distance formula is (x - h)2 + (y - k)2 = r2
- if($check<=pow($cir_r,2)){
- echo "Точката се намира в кръга";
- }
- else{
- echo "Точката е извън кръга";
- }
- }
- else{
- echo "Некоректно въведена стойност, моля въведете числена стойност в полетата!";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement