Skip to content

Commit

Permalink
Cleanup (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
JstnMcBrd authored Apr 6, 2024
1 parent f31fc4a commit 9682a62
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 292 deletions.
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ class Object {
reflectivity?: number = 0;
};

/** The specific values necessary for Planes. */
class Plane extends Object {
/** Defines this object as a Plane. */
type: string = "plane";

/** Any position on the plane. */
position: Position = [0, 0, 0];

/** The direction the plane faces. */
normal: Direction;
};

/** The specific values necessary for Circles. */
class Circle extends Object {
/** Defines this object as a Circle. */
Expand All @@ -172,18 +184,6 @@ class Circle extends Object {
radius: number;
};

/** The specific values necessary for Planes. */
class Plane extends Object {
/** Defines this object as a Plane. */
type: string = "plane";

/** Any position on the plane. */
position: Position = [0, 0, 0];

/** The direction the plane faces. */
normal: Direction;
};

/** The specific values necessary for Polygons. */
class Polygon extends Object {
/** Defines this object as a Polygon. */
Expand All @@ -193,18 +193,6 @@ class Polygon extends Object {
vertices: Array<Position>;
};

/** The specific values necessary for Spheres. */
class Sphere extends Object {
/** Defines this object as a Sphere. */
type: string = "sphere";

/** The center of the Sphere. */
position: Position;

/** The radius of the Sphere. Must be greater than 0. */
radius: number;
};

/**
* The specific values necessary for Triangles.
* The algorithm for Triangle intersections is slightly faster than Polygons,
Expand All @@ -217,6 +205,18 @@ class Triangle extends Polygon {
/** The number of vertices must be ONLY 3. */
};

/** The specific values necessary for Spheres. */
class Sphere extends Object {
/** Defines this object as a Sphere. */
type: string = "sphere";

/** The center of the Sphere. */
position: Position;

/** The radius of the Sphere. Must be greater than 0. */
radius: number;
};

// More types of objects can be added later.
// In the meantime, most kinds of objects can be modeled with Polygons.
```
Expand All @@ -234,3 +234,5 @@ To run the type-checker, use
```sh
mypy .
```

The linter and type-checker will run automatically on pull requests, and success is required to merge.
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ignore = [
"D203", # Conflicts with D211 - https://docs.astral.sh/ruff/rules/one-blank-line-before-class/
"D206", # Using tabs - https://docs.astral.sh/ruff/rules/indent-with-spaces/
"D212", # Conflicts with D213 - https://docs.astral.sh/ruff/rules/multi-line-summary-first-line/
"E501", # Makes code messy - https://docs.astral.sh/ruff/rules/line-too-long/
"EM101", # Convenience - https://docs.astral.sh/ruff/rules/raw-string-in-exception/
"EM102", # Convenience - https://docs.astral.sh/ruff/rules/f-string-in-exception/
"ERA001", # False positives - https://docs.astral.sh/ruff/rules/commented-out-code/
Expand Down
21 changes: 7 additions & 14 deletions src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,11 @@ def parse_arguments() -> tuple[str, str, int, int, int, bool]:
# The ArgumentParser will take care of parsing them.)
load_dotenv()
env_scene = getenv("scene")
env_output = getenv("output",
default=DEFAULT_OUTPUT)
env_width = getenv("width",
default=str(DEFAULT_WIDTH))
env_height = getenv("height",
default=str(DEFAULT_HEIGHT))
env_reflection_limit = getenv("reflection-limit",
default=str(DEFAULT_REFLECTION_LIMIT))
env_progress_bar = getenv("progress-bar",
default=str(DEFAULT_PROGRESS_BAR))
env_output = getenv("output", default=DEFAULT_OUTPUT)
env_width = getenv("width", default=str(DEFAULT_WIDTH))
env_height = getenv("height", default=str(DEFAULT_HEIGHT))
env_reflection_limit = getenv("reflection-limit", default=str(DEFAULT_REFLECTION_LIMIT))
env_progress_bar = getenv("progress-bar", default=str(DEFAULT_PROGRESS_BAR))

# Retrieve arguments overrides from command line
# (A command line argument is only required if the environment variable is missing.)
Expand Down Expand Up @@ -75,12 +70,10 @@ def parse_arguments() -> tuple[str, str, int, int, int, bool]:
reflection_limit: int = parsed.reflection_limit
progress_bar: bool = parsed.progress_bar

return scene_file_path, output_file_path, width, height, \
reflection_limit, progress_bar
return scene_file_path, output_file_path, width, height, reflection_limit, progress_bar


def main(scene_file_path: str, output_file_path: str, width: int, height: int,
reflection_limit: int, progress_bar: bool) -> None:
def main(scene_file_path: str, output_file_path: str, width: int, height: int, reflection_limit: int, progress_bar: bool) -> None:
"""Import, ray-trace, and export."""
# Assert the output file extension is supported
assert_supported_extension(output_file_path)
Expand Down
Loading

0 comments on commit 9682a62

Please sign in to comment.