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

com.aparapi.examples.oopnbody.Perspective Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2016 - 2018 Syncleus, Inc.
 *
 * 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 com.aparapi.examples.oopnbody;

class Perspective {
   private float xeye;

   private float yeye;

   private float zeye;

   private float xat;

   private float yat;

   private float zat;

   public float zoomFactor;

   /**
    * 

Constructor for Perspective.

*/ public Perspective() { } /** *

Constructor for Perspective.

* * @param xeye a float. * @param yeye a float. * @param zeye a float. * @param xat a float. * @param yat a float. * @param zat a float. * @param zoomFactor a float. */ public Perspective(float xeye, float yeye, float zeye, float xat, float yat, float zat, float zoomFactor) { this.xeye = xeye; this.yeye = yeye; this.zeye = zeye; this.xat = xat; this.yat = yat; this.zat = zat; this.zoomFactor = zoomFactor; } /** *

Getter for the field xeye.

* * @return a float. */ public float getXeye() { return xeye; } /** *

Setter for the field xeye.

* * @param xeye a float. */ public void setXeye(float xeye) { this.xeye = xeye; } /** *

Getter for the field yeye.

* * @return a float. */ public float getYeye() { return yeye; } /** *

Setter for the field yeye.

* * @param yeye a float. */ public void setYeye(float yeye) { this.yeye = yeye; } /** *

Getter for the field zeye.

* * @return a float. */ public float getZeye() { return zeye; } /** *

Setter for the field zeye.

* * @param zeye a float. */ public void setZeye(float zeye) { this.zeye = zeye; } /** *

Getter for the field xat.

* * @return a float. */ public float getXat() { return xat; } /** *

Setter for the field xat.

* * @param xat a float. */ public void setXat(float xat) { this.xat = xat; } /** *

Getter for the field yat.

* * @return a float. */ public float getYat() { return yat; } /** *

Setter for the field yat.

* * @param yat a float. */ public void setYat(float yat) { this.yat = yat; } /** *

Getter for the field zat.

* * @return a float. */ public float getZat() { return zat; } /** *

Setter for the field zat.

* * @param zat a float. */ public void setZat(float zat) { this.zat = zat; } /** *

Getter for the field zoomFactor.

* * @return a float. */ public float getZoomFactor() { return zoomFactor; } /** *

Setter for the field zoomFactor.

* * @param zoomFactor a float. */ public void setZoomFactor(float zoomFactor) { this.zoomFactor = zoomFactor; } /** *

getRadius.

* * @return a float. */ public float getRadius() { return (float) Math.sqrt(xeye * xeye + yeye * yeye + zeye * zeye); } /** *

getTheta.

* * @return a float. */ public float getTheta() { if( getRadius() == 0f) return 0f; return (float) Math.acos(zeye / getRadius()); } /** *

getPhi.

* * @return a float. */ public float getPhi() { if(xeye == 0f) return 0f; return (float) Math.atan(yeye / xeye); } /** *

setRadius.

* * @param radius a float. */ public void setRadius(float radius) { final float theta = getTheta(); final float phi = getPhi(); xeye = radius * ((float)Math.cos(phi)) * ((float)Math.sin(theta)); yeye = radius * ((float)Math.sin(theta)) * ((float)Math.sin(phi)); zeye = radius * ((float)Math.cos(theta)); } /** *

setTheta.

* * @param theta a float. */ public void setTheta(float theta) { final float radius = getRadius(); final float phi = getPhi(); xeye = radius * ((float)Math.cos(phi)) * ((float)Math.sin(theta)); yeye = radius * ((float)Math.sin(theta)) * ((float)Math.sin(phi)); zeye = radius * ((float)Math.cos(theta)); } /** *

setPhi.

* * @param phi a float. */ public void setPhi(float phi) { final float radius = getRadius(); final float theta = getTheta(); xeye = radius * ((float)Math.cos(phi)) * ((float)Math.sin(theta)); yeye = radius * ((float)Math.sin(theta)) * ((float)Math.sin(phi)); zeye = radius * ((float)Math.cos(theta)); } /** {@inheritDoc} */ @Override public String toString() { return "Perspective{" + " xeye=" + xeye + ", yeye=" + yeye + ", zeye=" + zeye + " radius=" + getRadius() + ", theta=" + getTheta() + ", phi=" + getPhi() + ", xat=" + xat + ", yat=" + yat + ", zat=" + zat + ", zoomFactor=" + zoomFactor + '}'; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy