IntersectionConfig¶
- class dnois.optics.rt.IntersectionConfig(max_iteration: int = 10, threshold: float = 2e-08, threshold_strict: float = 2e-08, update_bound: float = 5.0, epsilon: float = 1e-09, force_before: bool = True, force_non_negative: bool = False, use_analytical: bool = True)¶
Configuration for intersection-determination algorithm.
- classmethod from_dict(d: dict) Self ¶
Constructs an instance of
cls
from adict
.- Parameters:
d (dict) – A
dict
typically returned byto_dict()
.- Returns:
An instance of
cls
.
- classmethod load_json(file, **kwargs) Self ¶
Constructs an instance of
cls
through loading JSON from a file, converting it to adict
and then callingfrom_dict()
.- Parameters:
file (str or
pathlib.Path
or file-like object) – The JSON file to load. Either its path (str
orpathlib.Path
) or a file-like object.kwargs – Keyword arguments passed to
json.load()
.
- Returns:
An instance of
cls
.
- save_json(file, **kwargs)¶
Save
self
into a JSON filefile
.- Parameters:
file – The JSON file to save. Either its path (
str
orpathlib.Path
) or a file-like object.kwargs – Keyword arguments passed to
json.dump()
.
- to_dict(keep_tensor: bool = True) dict[str, Any] ¶
Converts
self
into adict
which recursively contains only primitive Python objects.- Return type:
dict
- to_json(**kwargs) str ¶
Converts
self
into a JSON string.- Parameters:
kwargs – Keyword arguments passed to
json.dumps()
.- Return type:
str
- default: Self = IntersectionConfig(max_iteration=10, threshold=2e-08, threshold_strict=2e-08, update_bound=5.0, epsilon=1e-09, force_before=True, force_non_negative=False, use_analytical=True)¶
Default configuration.
- epsilon: float = 1e-09¶
A small value to avoid division by zero.
- force_before: bool = True¶
Whether to mark rays whose origins are not before (after) the surface as invalid in intersection-determination during forward (backward) ray tracing.
- force_non_negative: bool = False¶
Whether to mark rays whose marching distance are negative as invalid in intersection-determination.
- max_iteration: int = 10¶
Number of maximum iterations in Newton’s method.
- threshold: float = 2e-08¶
Threshold for residual error in Newton’s method.
- update_bound: float = 5.0¶
Maximum absolute update to the variable to be solved in Newton’s method.
- use_analytical: bool = True¶
Use analytical solution rather than Newton’s method to determine ray-surface intersection if available.