1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-05 06:57:27 +02:00

Merge branch 'camera_fov' of https://github.com/martinbudden/NopSCADlib into martinbudden-camera_fov

This commit is contained in:
Chris Palmer
2021-12-14 17:49:08 +00:00
2 changed files with 18 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ function camera_lens_offset(type) = type[3]; //! Offset of the lens center fro
function camera_lens(type) = type[4]; //! Stack of lens parts, can be round, rectangular or rounded rectangular, with optional tapered aperture
function camera_connector_pos(type) = type[5]; //! The flex connector block for the camera itself's position
function camera_connector_size(type)= type[6]; //! The flex connector block for the camera itself's size
function camera_fov(type) = type[7]; //! The field of view of the camera lens
module camera_lens(type, offset = 0, show_lens = true) //! Draw the lens stack, with optional offset for making a clearance hole
color(grey(20))
@@ -57,7 +58,7 @@ module camera_lens(type, offset = 0, show_lens = true) //! Draw the lens stack,
}
}
module camera(type, show_lens = true) { //! Draw specified PCB camera
module camera(type, show_lens = true, fov_distance = 0, fov = undef) { //! Draw specified PCB camera
vitamin(str("camera(", type[0], "): ", type[1]));
pcb = camera_pcb(type);
@@ -66,6 +67,18 @@ module camera(type, show_lens = true) { //! Draw specified PCB camera
translate_z(pcb_thickness(pcb)) {
camera_lens(type, show_lens = show_lens);
if (show_lens&& fov_distance > 0) {
lens = camera_lens(type);
fov = is_undef(fov) ? camera_fov(type) : fov;
if (is_list(fov))
#translate_z(lens[2][0].z) // note: use of # is deliberate, to show highlighted field of view
translate(camera_lens_offset(type))
hull() {
cube([lens[1][1]/2, lens[1][1]/2, eps], center=true);
translate_z(fov_distance)
cube([2 * fov_distance * tan(fov.x / 2), 2 * fov_distance * tan(fov.y / 2), eps], center=true);
}
}
conn = camera_connector_size(type);
if(conn) {

View File

@@ -32,7 +32,8 @@ rpi_camera_v1 = ["rpi_camera_v1", "Raspberry Pi camera V1", rpi_camera_v1_pcb, [
[[0, 0, 4], 7.5 / 2],
[[0, 0, 5], 5.5 / 2, [1.5/2, 2/2, 0.5]],
],
[0, 12 - 1.5 - 2.5], [8, 5, 1]
[0, 12 - 1.5 - 2.5], [8, 5, 1],
[54, 41] // FOV
];
rpi_camera_v2_pcb = ["", "", 25, 23.862, 1, 2, 2.2, 0, "green", false, [[2, -2], [-2, -2], [2, -14.5], [-2, -14.5]],
@@ -47,7 +48,8 @@ rpi_camera_v2 = ["rpi_camera_v2", "Raspberry Pi camera V2", rpi_camera_v2_pcb, [
[[0, 0, 4], 7.5 / 2],
[[0, 0, 5], 5.5 / 2, [1.5/2, 2/2, 0.5]],
],
[-13.8 + 12.5, 23.862 / 2 - 4.7], [8.5, 4, 1]
[-13.8 + 12.5, 23.862 / 2 - 4.7], [8.5, 4, 1],
[62.2, 48.8] // FOV
];
rpi_camera_pcb = ["", "", 36, 36, 1.6, 0, 3.2, 0, "green", false, [[3.5, -3.5], [-3.5, -3.5], [3.5, 3.5], [-3.5, 3.5]],