Advertisement
Guest User

Sphere calculation

a guest
Jun 8th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1.     private void create(TexturedModel model) {
  2.         Vector3f center = Vector3f.add(model.getMax(), model.getMin(), null);
  3.         center = new Vector3f(center.x / 2,center.y / 2,center.z / 2);
  4.        
  5.         this.center = center;
  6.         Vector3f[] vertices = model.getVertices();
  7.         float length = Float.MIN_VALUE;
  8.         for(int i = 0; i < vertices.length;i++) {
  9.        
  10.            
  11.             for(int j = 1; j < vertices.length;j++) {
  12.                 Vector3f v0 = vertices[i];
  13.                 Vector3f v1 = vertices[j];
  14.                
  15.                 float tmp = Vector3f.dot(v0, v1);
  16.                
  17.                 if(tmp < length) {
  18.                     length = tmp;
  19.                 }
  20.             }
  21.         }
  22.        
  23.         this.radius = length;
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement