⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spherecurvesolid.java

📁 基于面向对象的数据库编程
💻 JAVA
字号:
package brgeometry;

import helper.ProBag;

/**
 * <p>Title: Broundary Rrepresentaion</p>
 * <p>Description: 球体</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: USTC</p>
 * @author unascribed
 * @version 1.0
 */

public class SphereCurveSolid
    extends CurveSolid {

  private SphereCurveFace sphereCurveface;

  private double radius;
  public String name;
  // public double volume,surface;
  public String getName (){
    return this .name;
  }

  public SphereCurveSolid(SphereCurveFace sphereCurveface) {
    this.sphereCurveface = sphereCurveface;
    this.setVolume(this.getVolume());
  }

  public SphereCurveSolid() {
    this.setVolume(this.getVolume());
  }

  //实现对于体积的计算
  public double getRadius() {
    return this.radius;
  }

  public double getVolume() {

    return 3.1415926 * this.radius * this.radius * this.radius * 4 / 3;
  }
  public void setName (String name )
  {
    this.name=name;

  }

  //实现对于面积的计算
  public double getSurface() {
    return 3.1415926 * this.radius * this.radius * 4;
  }

  //定义属性设置的统一的接口
  public void setPro(ProBag proBag) {
    double radius = proBag.getRadius();
    this.sphereCurveface.getRoundCurveEdge().getcirclePoint().translate(radius -
        this.radius, 0, 0);
    this.radius = radius;

    this.setVolume(this.getVolume());
    this.setSurface(this.getSurface());

  }

  public ProBag getPro() {
    ProBag probag = new ProBag();
    probag.setRadius(getRadius());
    return probag;
  }

  public void init(ProBag proBag) {

    this.radius = proBag.getRadius();

    Vertice v0 = new Vertice(0, 0, 0);
    Vertice centralPoint = new Vertice(v0.getX(), v0.getY(), v0.getZ());
    Vertice circlePoint = new Vertice(v0.getX() + this.radius, v0.getY(), v0.getZ());

    //用点确定边
    RoundCurveEdge roundCurveEdge = new RoundCurveEdge(centralPoint,
        circlePoint);
    //用边确定面
    SphereCurveFace sphereCurveface = new SphereCurveFace(roundCurveEdge);
    //用面确定体

    this.sphereCurveface = sphereCurveface;

    this.setVolume(this.getVolume());
    this.setSurface(this.getSurface());

  }

  //定义对于修改的计算。包括移动,缩放和旋转
  //将指定ID的任何体移动指定的距离
  public void tanslate(Vertice v) {
    this.sphereCurveface.getRoundCurveEdge().getcentralPoint().translate(v);
    this.sphereCurveface.getRoundCurveEdge().getcirclePoint().translate(v);
  }

  //将指定ID的任何体相对于x.y.z旋转一个角度其中,xyz是弧度的描述
  public void rotate(Vertice v) {}

  //将指定的ID的任何体缩放一个指定的倍数
  public void scale(double times) {
    this.tanslate(this.sphereCurveface.getRoundCurveEdge().getcentralPoint().
                  mirror());
    ProBag probag = new ProBag();
    probag.setRadius(this.radius * times);
    setPro(probag);
    this.tanslate(this.sphereCurveface.getRoundCurveEdge().getcentralPoint());
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -