fd9ba89f5528843e3e650fc17b5146b021bcd4d1
3 Sphere::Sphere(const Vec3f
& center
, float radius
, Shader
* shader
)
15 Sphere::Intersect(Ray
& ray
)
17 float A
= ray
.direction().dot(ray
.direction());
18 float C
= (ray
.origin()-m_center
).dot(ray
.origin()-m_center
) - m_radius
*m_radius
;
19 float B
= 2 * ray
.direction().dot(ray
.origin()-m_center
);
24 float root
= sqrtf(B
*B
-4*A
*C
);
25 float t
= (-B
-root
)/(2.0f
*A
);
31 t
= (-B
+root
)/(2.0f
*A
);
32 if( t
< Epsilon
|| t
> ray
.t())
43 Sphere::GetNormal(Ray
& ray
)
45 Vec3f p
= ray
.origin()+ray
.direction()*ray
.t();
46 Vec3f N
= (p
-m_center
);
59 Sphere::InVoxel(const Box
& box
)
This page took 0.040124 seconds and 3 git commands to generate.