/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Capitulo_3.Vectores;

/**
 *
 * @author felix
 */
public class Vector {
    private double x;
    private double y;
    
    public Vector(double valx, double valy) {
        x = valx;
        y = valy;
    }
    
    public static Vector Suma(Vector d1, Vector d2) {
        double px, py;
        px = d1.x + d2.x;
        py = d1.y + d2.y;        
        return new Vector(px, py);
    }
    
    public static Vector Resta(Vector d1, Vector d2) {
        double px, py;
        px = d1.x - d2.x;
        py = d1.y - d2.y;
        
        return new Vector(px, py);
    }
    
    public static double ProductoEscalar(Vector d1, Vector d2) {
        return (d1.x*d2.x + d1.y*d2.y);
    }
    
    @Override
    public String toString() {
        
        String aux;
        if (y >= 0) 
            aux = x + " (i) " + " + " + y + " (j) "; 
        else
            aux = x + " (i) " + " - " + (-y) + " (j) "; 
        
        return aux;
    }
}
