Skip to content

Commit

Permalink
tidy up pre merge
Browse files Browse the repository at this point in the history
  • Loading branch information
coillteoir committed Jun 7, 2024
1 parent 565a910 commit 476c920
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 8 additions & 1 deletion src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ pub fn compile(data: &str) -> String {
0,
tokens[1].parse::<f32>().expect("non numeric value given"),
)),
"sphere" => result.push_str(&sphere(Point::new(0.0, 0.0, 0.0), 1.0, 10).unwrap()),
"sphere" => result.push_str(
&sphere(
Point::new(0.0, 0.0, 0.0),
tokens[1].parse::<f32>().expect("non numeric value given"),
10,
)
.unwrap(),
),
"#" => todo!(),
&_ => eprintln!("{} not supported", tokens[0]),
}
Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ use std::path::Path;
struct Args {
#[arg(help = "source file")]
source: String,
#[arg(help = "output file", default_value="")]
#[arg(help = "output file", default_value = "")]
output: String,
}

fn main() {

println!("{}", compile("sphere 1"));

let args = Args::parse();
Expand Down
8 changes: 4 additions & 4 deletions src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ pub fn sphere(origin: Point, radius: f32, _detail: u32) -> Result<String, String

let points = vec![
//top
Point::new(origin.x, origin.y + (radius * (PI/2.0).sin()), origin.z),
Point::new(origin.x, origin.y + (radius * (PI / 2.0).sin()), origin.z),
//bottom
Point::new(origin.x, origin.y + (radius * (PI/-2.0).sin()), origin.z),
Point::new(origin.x, origin.y + (radius * (PI / -2.0).sin()), origin.z),
//north
Point::new(origin.x, origin.y, origin.z + (radius * (PI/2.0).sin())),
Point::new(origin.x, origin.y, origin.z + (radius * (PI / 2.0).sin())),
//south
Point::new(origin.x, origin.y, origin.z + (radius * (PI/-2.0).sin())),
Point::new(origin.x, origin.y, origin.z + (radius * (PI / -2.0).sin())),
//east
Point::new(origin.x + (radius * (0.0_f32).cos()), origin.y, origin.z),
//west
Expand Down

0 comments on commit 476c920

Please sign in to comment.