domingo, 24 de novembro de 2013

Pythagorean theorem without formulas, you believe everything they tell you? Take the test! =) Part 1

This is the first publication to do regarding education. Present a java code that performs the calculation of the distance between two points , in this case, the points that form the hypotenuse of an isosceles right triangle with sides 1.1 , hypotenuse ( hip ) . If we did this procedure with a school rule would have a very inaccurate 1.4 cm and our eyes perceive value a bit more to improve our accuracy , we can make a proportionally larger triangle . If we did 10x , ie 10,10,10 * hip sides would have to answer 10 * higher , however , our rule now gives the value of 14.1 cm and again our eyes leave us in doubt . 100x greater if we did we can assume that the value would be 141.4 cm . Try it yourself. There is a statement that says that if we would have the perfectly precise calculation of the amount equivalent to the value of the hypotenuse square 2 ( 1.4142135623730950 ... ) root , note that the initial idea I had to measure with a ruler was giving us values increasingly accurate. I had the idea to make a program in java that utilizes methods for drawing lines and points . I made the triangle with sides 1.1 , and calculating the hypotenuse has great need 1.4142135623730951 error with only the last digit (1) when compared with the calculation made by other more accurate methods continue to ... 0488016887242097 ... therefore the program also has its limitations but let's assume that this approximation to have the value of two as the same squared value is approximately 2.0000000000000001 . But recently I discovered that montássemos a triangle of sides 1 , square root of 2 , hypotenuse , we would have the amazing value of the square root of 3 as shown in the link ( http://www.geom.uiuc.edu/ ~ demo5337 / Group3/spiral.gif ) . In the figure, one side of all other triangles has written value, but it is equal to 1 , namely sides 1, 1, to the first quarter . For one second sides , a, b (note that a = 2 and b = root root 3) and so on successively . The code below will show my algorithm . If you want to run the code just copy it to a java IDE ( Eclipse or Netbeans for ex.) . But some outlets already advance : programmed to never stop until at least not burst where the program memory. The first part confinement here , part 2 will include graphics.
raiz de 1 1.0
raiz de 2 1.4142135623730951
raiz de 3 1.7320508075688774
raiz de 4 2.0
raiz de 5 2.23606797749979
raiz de 6 2.4494897427831783
raiz de 7 2.6457513110645907
raiz de 8 2.8284271247461903
raiz de 9 3.0000000000000004
raiz de 10 3.16227766016838
<?java


import java.awt.*;
import java.applet.*;
import java.awt.geom.*;

public class Line2D1 extends Applet {

    private Line2D Shape1;
    private Line2D Shape2;
    private Line2D Shape3;
    private Line2D iShape;
    //double diagonal;
    private Point2D Point1;
    private Point2D iPoint;
    double raizquadrada;
    boolean continua = true;

    public static void main(String[] args) {
        Line2D1 mede = new Line2D1();
        mede.raiziterativa();
        
    }

    public void raiziterativa() {

        boolean continua = true;

        while (continua == true) {
            iPoint = new Point2D.Double(0, raizquadrada);
            raizquadrada = iPoint.distance(Shape1.getP2());
            iShape = new Line2D.Double(Shape1.getP1(), iPoint);
            long i;
            i = Math.round(Math.pow(raizquadrada, 2)) ;

            System.out.println("raiz de " + i + " " + raizquadrada);
        }

    }

    public Line2D1() {
        Shape1 = new Line2D.Double(0, 0, 1, 0); // linha vertical vetor da esqPdir
        //Shape2 = new Line2D.Double();
        //Shape2.setLine(0.F, 0.F, 0.F, 1.F); // linha horizontal vetor de cimaPbaixo cpb
        //Shape3 = new Line2D.Double(120, 0, 20, 100); // diagonal cpb dpe.
        Point1 = new Point2D.Double(0, 1);
        Shape2 = new Line2D.Double(Shape1.getP1(), Point1);
        Shape3 = new Line2D.Double(Shape1.getP2(), Point1);

    }

    @Override
    public void paint(Graphics g) {
        Graphics2D g2D;
        boolean Hit;

        g2D = (Graphics2D) g;

        Hit = Shape1.intersectsLine(Shape2);
        g2D.drawString("intersects = " + Hit, 20, 145);

        g2D.draw(Shape1);
        g2D.draw(Shape2);
        g2D.draw(Shape3);

    }

}


Nenhum comentário:

Postar um comentário