All Downloads are FREE. Search and download functionalities are using the official Maven repository.

one.empty3.tests.AngleMovment Maven / Gradle / Ivy

There is a newer version: 2024.5.10
Show newest version
/*
 * Copyright (c) 2022-2023. Manuel Daniel Dahmen
 *
 *
 *    Copyright 2012-2023 Manuel Daniel Dahmen
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package one.empty3.tests;

import one.empty3.library.core.raytracer.tree.AlgebraicFormulaSyntaxException;
import one.empty3.library.core.raytracer.tree.AlgebricTree;
import one.empty3.library.core.raytracer.tree.TreeNodeEvalException;
import one.empty3.library.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class AngleMovment {
    AlgebricTree[] tree;
    List fxs = new ArrayList();
    HashMap vars;

    public AngleMovment(int size) {
        tree = new AlgebricTree[size];
        vars = new HashMap<>(size);
    }

    public void var(String var, double val) {
        vars.put(var, val);
    }

    public void setFormula(int index, String chars) {

        tree[index] = new AlgebricTree(chars, vars);
        tree[index].setParametersValues(vars);
        try {
            tree[index].construct();
        } catch (AlgebraicFormulaSyntaxException e) {
            e.printStackTrace();
        }
    }

    public double calcculerAngle(int index) {
        try {
            tree[index].setParametersValues(vars);
            tree[index].construct();
            return (double) (tree[index].eval());
        } catch (TreeNodeEvalException | AlgebraicFormulaSyntaxException e) {
            e.printStackTrace();
        }
        return Double.NaN;
    }

    public void addFx(String formulaN) {
        try {
            fxs.add(new AlgebricTree(formulaN));

        }
        catch (AlgebraicFormulaSyntaxException ex) {
            ex.printStackTrace();
        }
    }

    public Point3D getPoint3D() {
        double [] values = new double[tree.length];
        for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy