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

one.empty3.library.Point3D.new Maven / Gradle / Ivy

There is a newer version: 2024.5.10
Show newest version
package one.empty3.library;
/*
 *  This file is part of Empty3.
 *
 *     Empty3 is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     Empty3 is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with Empty3.  If not, see . 2
 */

/*
 * This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see 
 */
import java.awt.Color;
import java.util.*;


public class Point3D extends Representable {
     public static DoubleArray da;
     private int start;
     private int n;
     public static final int mem = 10000000;
     public int length() {
         return n;
     }

     public Point3D() {
         
         super();
         
         if(da==null)
              da = new DoubleArray(10, mem);
         n = 3;
         start = da.addDoubles(n);
          this.n = n;
     }

     public Point3D(int n) {
          super();
          if(da==null)
              da = new DoubleArray(10, mem);
          start = da.addDoubles(n);
          this.n = n;
     }
/*
     public Point3D(Point3D v1, double... c) {
         this(v1.length()+c.length);
         int i; int j=0;
         for( i=start; i=v[j].length()) {
                 k=0;
                 j++;
             }
             if(j>=m)
                   break;
         }
     }
     public static void start() {
         da.addToStack();
     }
     public static void end() {
         da.removeFromStack();
     }
     /*
     public static int [] stack() {
          return da.stack;
     }
   */
    /*__
     * *
     * axe X vector
     */
    public static final Point3D X = new Point3D(1d, 0d, 0d);
    /*__
     * *
     * axe Y vector
     */
    public static final Point3D Y = new Point3D(0d, 1d, 0d);
    /*__
     * *
     * axe Z vector
     */
    public static final Point3D Z = new Point3D(0d, 0d, 1d);
    /*__
     * *
     * O0 origin
     */
    public static final Point3D O0 = new Point3D(0d, 0d, 0d);
    /*__
     * *
     * Point "Infinite" limite pour Z-Buffer
     */
    public static final Point3D INFINI = new Point3D(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
    /*__
     * *
     * Pour le tracé de surface normale au point
     */
    protected Point3D normale;
    /*__
     * *
     * id
     */

    
    /*__
     * *
     *
     * @param x0 coordArr-coordonnée
     */
    public Point3D(double... x0) {
         this(x0.length);
         int i = 0;
         
         for(double d : x0) {
              da.setDoubles(start + i, d);
              i++;
         }
    }
/*__
     * *
     *
     * @param x0 coordArr-coordonnée
     * @param y0 y-coordonnée
     * @param z0 z-coordonnée
     */
    public Point3D(Double x0, Double y0, Double z0, ITexture t) {
      
         this(x0, y0, z0);
        texture(t);
    }

    /*__
     * *
     * Initialise à partir d'un tableau
     *
     * @param x0 coordonnées (>3)
     */
  /*  public Point3D(Double ... x0) {
         this(x0.length);
        int i=0;
        for(Double d : x0) {
         set(i, d);
         i++;
        }
        
    }*/

    public Point3D(Double[] x0, ITexture t) {
         this(x0.length);
        int i=0;
        for(Double d : x0) {
         set(i, d);
         i++;
        }
        texture(t);
    }
  

    public Point3D(StructureMatrix coordArr) {
        this(coordArr.data1d.size());
        for(int i= 0; i=0 && i<3 && coordArr.data1d.size()==3)
            return da.getDouble(start+ i);
       /* else
            try {
                throw new Throwable("vec coordArr out of bounds or array dim error\nValues="+coordArr.toString()+"\nSize="+coordArr.data1d.size());
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        return Double.NaN;*/
    }
    public Point3D scale() {
        if(scale==null)
        {
            return this;
        }
         return new Point3D(get(0)*scale.get(1),get(1)*scale.get(1),get(2)*scale.get(2));
    }

    public List getDoubleArray() {
        List coordArr = new ArrayList<>();
        for(int i = 0; i getCoordArr() {
        StructureMatrix coordArr = new StructureMatrix<>(1, Double.class);
         for(int i= 0; i coordArr) {
        for(int i= 0; i * add-> * <- mult .,* min max->
     * exp div set <- sub div  get sum fx? 
     * new start end 
    *//*
    public static int[] op(String po, int... p1){
        switch(po) {
                case "+":
                for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy