/*
 * 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 baseclasses;

import java.io.IOException;
import org.apache.commons.math3.linear.BlockRealMatrix;

/**
 *
 * @author Alex
 */
public class FrameTransformation {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        String fileName = "Scan 4-9-15.obj";
        
        ObjImport scanImport = new ObjImport(fileName);
        try {
            scanImport.read();
        } catch (IOException e) {
            System.out.println("wat.");
        }
        Point[] pts = scanImport.getPoints();
        
        BlockRealMatrix ans = new BlockRealMatrix(3, 3);
        BlockRealMatrix trans = new BlockRealMatrix(3, 1);
        
        double theta = -3.0;
        theta = Math.toRadians(theta);
        double cos = Math.cos(theta);
        double sin = Math.sin(theta);
        
        ans.setEntry(0, 0, .82);
        ans.setEntry(0, 1, .56);
        ans.setEntry(0, 2, .09);        
        ans.setEntry(1, 0, -.55);
        ans.setEntry(1, 1, .82);
        ans.setEntry(1, 2, -.13);
        ans.setEntry(2, 0, -.15);
        ans.setEntry(2, 1, .06);
        ans.setEntry(2, 2, .99);
        
        trans.setEntry(0,0, -7.12);
        trans.setEntry(1,0, -98.17);
        trans.setEntry(2,0, -35.55);
        
        Frame fr1 = new Frame(ans, trans);
        pts = fr1.transform(pts);
        
        System.out.println("\nExporting");
        System.out.println("=======================");
        ObjExport ex = new ObjExport("Out-" + fileName, 
                pts, scanImport.getTriangles());
        try {
            ex.write();
        } catch (IOException e) {
            System.out.println("Error on Export");
        }
    }
    
}
