Putting some Sphere into a Vec
This commit is contained in:
+17
-1
@@ -105,4 +105,20 @@ struct Sphere {
|
||||
radius: f64,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
impl Sphere {
|
||||
fn new(point: Point3, radius: f64) -> Sphere {
|
||||
Sphere { point, radius }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let sphere1 = Sphere::new(Point3::new(0.0, 0.0, 0.0), 25.0);
|
||||
let sphere2 = Sphere::new(Point3::new(1.0, -45.4, 3.55), 2.0);
|
||||
let sphere3 = Sphere::new(Point3::new(3.0, 2.0, 1.0), 0.5);
|
||||
|
||||
let mut v = Vec::new();
|
||||
|
||||
v.push(sphere1);
|
||||
v.push(sphere2);
|
||||
v.push(sphere3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user