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

📄 cylindercurvesolid.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 CylinderCurveSolid
    extends CurveSolid {
  // public double volume,surface;
  private double radius;
  private double high;
  public String name;

  private CylinderCurveFace cylinderCurveface;
  private RoundPlaneFace uperFace;
  private RoundPlaneFace lowerFace;

  public CylinderCurveSolid(RoundPlaneFace lowerFace, RoundPlaneFace uperFace,
                            CylinderCurveFace cylinderCurveface) {
    this.lowerFace = lowerFace;
    this.uperFace = uperFace;
    this.cylinderCurveface = cylinderCurveface;
  }

  public CylinderCurveSolid() {}

  public double getHigh() {
    return this.high;
  }
  public String  getName(){
    return this.name;
  }

  public double getRadius() {
    return this.radius;
  }

  public void setName (String name )
  {
    this.name=name;
  }

  //实现对于体积的计算
  public double getVolume() {
    double r = cylinderCurveface.getRadius();
    return 3.1415926 * r * r * cylinderCurveface.getHigh();
  }

  //实现对于面积的计算
  public double getSurface() {
    return this.cylinderCurveface.getarea() + this.lowerFace.getarea() +
        this.uperFace.getarea();
  }

  //定义属性设置的统一的接口
  public void setPro(ProBag proBag) {

    double high = proBag.getHigh();
    double radius = proBag.getRadius();

    this.lowerFace.getRoundCurveEdge().getcirclePoint().translate(radius -
        this.radius, 0, 0);
    this.uperFace.getRoundCurveEdge().getcentralPoint().translate(0, 0,
        high - this.high);
    this.uperFace.getRoundCurveEdge().getcirclePoint().translate(radius -
        this.radius, 0, high - this.high);

    this.high = high;
    this.radius = radius;
    this.setVolume(this.getVolume());
    this.setSurface(this.getSurface());
  }

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

  public void init(ProBag proBag) {
    //用传入的参数求出点的位置
    //利用边长求出点的位置,然后确定边、确定面、确定体
    //用传入的参数求出点的位置
    this.radius = proBag.getRadius();
    this.high = proBag.getHigh();

    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());
    Vertice highPoint = new Vertice(v0.getX(), v0.getY() + this.high, v0.getZ());

    //用点确定边
    RoundCurveEdge hemline = new RoundCurveEdge(centralPoint, circlePoint);
    BeelineEdge highness = new BeelineEdge(centralPoint, highPoint);

    //用边确定面
    CylinderCurveFace cylinderCurveface = new CylinderCurveFace(hemline,
        highness);
    RoundPlaneFace uperFace = new RoundPlaneFace(hemline);
    RoundPlaneFace lowerFace = new RoundPlaneFace(hemline);

    //用面确定体
    this.lowerFace = lowerFace;
    this.uperFace = uperFace;
    this.cylinderCurveface = cylinderCurveface;

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

  }

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

  //将指定ID的任何体相对于x.y.z旋转一个角度其中,xyz是弧度的描述
  public void rotate(Vertice v) {};
  //将指定的ID的任何体缩放一个指定的倍数
  public void scale(double times) {
    this.tanslate(this.lowerFace.getRoundCurveEdge().getcentralPoint().mirror());
    ProBag probag = new ProBag();
    probag.setRadius(this.radius * times);
    probag.setHigh(this.high * times);
    setPro(probag);
    this.tanslate(this.lowerFace.getRoundCurveEdge().getcentralPoint());
  }
}

⌨️ 快捷键说明

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