refract¶
- dnois.refract(incident: Tensor, normal: Tensor, mu: Real | Tensor) Tensor ¶
- dnois.refract(incident: Tensor, normal: Tensor, n1: Real | Tensor, n2: Real | Tensor) Tensor
Computes direction of refractive ray given that of incident ray, normal vector and refractive indices. In descriptions below, subscript 1 means incident media and 2 means refractive media. All vectors have unit length. \(\mathbf{d}\) indicates directions of rays and \(\mathbf{n}\) indicates normal vector.
This function has two overloaded forms:
If relative refractive index \(\mu=n_1/n_2\) is given, returns
\[\mathbf{d}_2=\mu\mathbf{d}_1 +\sqrt{1-\mu^2[1-(\mathbf{n}\cdot\mathbf{d}_1)^2]}\mathbf{n} -\mu(\mathbf{n}\cdot\mathbf{d}_1)\mathbf{n}\]
- Parameters:
incident (Tensor) – Incident direction \(\mathbf{d}_1\). A tensor of shape
(..., 3)
.normal (Tensor) – Normal vector \(\mathbf{n}\). A tensor of shape
(..., 3)
.mu (float or Tensor) – Relative refractive index \(\mu\). A float or a tensor of shape
(...)
.
- Returns:
Refractive direction \(\mathbf{d}_2\). A tensor of shape
(..., 3)
.- Return type:
Tensor
If refractive indices in incident and refractive media \(n_1\), \(n_2\) are given, returns
\[n_2\mathbf{d}_2=n_1\mathbf{d}_1+ \left[\sqrt{n_2^2-n_1^2+(\mathbf{n}\cdot n_1\mathbf{d}_1)^2} -(\mathbf{n}\cdot n_1\mathbf{d}_1)\right]\mathbf{n}\]
- Parameters:
incident (Tensor) – Incident ray vector \(n_1\mathbf{d}_1\). A tensor of shape
(..., 3)
.normal (Tensor) – Normal vector \(\mathbf{n}\). A tensor of shape
(..., 3)
.n1 (float or Tensor) – Refractive index \(n_1\). A float or a tensor of shape
(...)
.n2 (float or Tensor) – Refractive index \(n_2\). A float or a tensor of shape
(...)
.
- Returns:
Refractive ray vector \(n_2\mathbf{d}_2\). A tensor of shape
(..., 3)
.- Return type:
Tensor
Hint
n1
,n2
andmu
can be negative.