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

eu.mihosoft.vrl.v3d.RoundedCylinder Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/*
 * 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 eu.mihosoft.vrl.v3d;

import java.util.ArrayList;
import java.util.List;

import eu.mihosoft.vrl.v3d.ext.quickhull3d.HullUtil;

// TODO: Auto-generated Javadoc
/**
 * The Class RoundedCube.
 * 
 * @author Michael Hoffer <[email protected]>
 */
public class RoundedCylinder extends Primitive {

    /** The properties. */
    private final PropertyStorage properties = new PropertyStorage();

    /** The corner radius. */
    private double cornerRadius = 2;
    
    /** The resolution. */
    private int resolution = 30;

	private double startRadius;

	private double endRadius;

	private double height;
	
	private int numCornerSlices;

    /**
     * Constructor. Creates a cylinder ranging from {@code [0,0,0]} to
     * {@code [0,0,height]} with the specified {@code radius} and
     * {@code height}. The resolution of the tessellation can be controlled with
     * {@code numSlices}.
     *
     * @param startRadius cylinder start radius
     * @param endRadius cylinder end radius
     * @param height cylinder height
     * @param numSlices number of slices (used for tessellation)
     */
    public RoundedCylinder(double startRadius, double endRadius, double height, int numSlices) {
		this.startRadius = startRadius;
		this.endRadius = endRadius;
		this.height = height;
		this.resolution = numSlices;
		setNumCornerSlices(6);
    }

    /**
     * Constructor. Creates a cylinder ranging from {@code [0,0,0]} to
     * {@code [0,0,height]} with the specified {@code radius} and
     * {@code height}. The resolution of the tessellation can be controlled with
     * {@code numSlices}.
     *
     * @param startRadius cylinder start radius
     * @param height cylinder height
     */
    public RoundedCylinder(double startRadius,  double height) {
		this.startRadius = startRadius;
		this.endRadius = startRadius;
		this.height = height;
		this.resolution = 30;
		setNumCornerSlices(6);
    }

    
    /* (non-Javadoc)
     * @see eu.mihosoft.vrl.v3d.Primitive#toPolygons()
     */
    @Override
    public List toPolygons() {
    	double minHeight = height-cornerRadius*2;
		ArrayList cylParts =new ArrayList<>();

		for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy