forked from secondsight/secondsight-hardware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lenses.scad
67 lines (62 loc) · 2.56 KB
/
lenses.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// secondsight Visor project
// Copyright 2013 by secondsight.io, Some Rights Reserved.
//
// Standardize a lens description for the secondsight headset.
// Creating a pseudo-object using a vector and a set of functions to access
// the defined attributes.
function lens_descriptor(name) = (name == "ebay 50x50") ? [ 50, 50, 42, 75, 2, 7.35, 12.45 ]
: name == "edmund 25x50" ? [ 25, 50, 44, 50, 1.25, 3, 4.25 ]
: name == "edmund 25x25" ? [ 25, 25, 23, 30, 1.25, 6.15, 7.4 ]
: name == "b&l 35 5x" ? [ 37, 50, 41, 60, 1.9, 3, 8 ]
: [];
function lens_diam( lens ) = lens[0];
function lens_rad( lens ) = lens[0]/2;
function lens_focal_length( lens ) = lens[1];
function lens_phone_offset( lens ) = lens[2];
function lens_fov( lens ) = lens[3];
function lens_rim_thickness( lens ) = lens[4];
function lens_front_height( lens ) = lens[5];
function lens_thickness( lens ) = lens[6];
function lens_back_height( lens ) = lens[6]-lens[5]-lens[4];
// Define a model of the lens described by 'lens'
//
// lens - descriptor for the lens to model
module lens_model( lens )
{
union()
{
//front
if( lens_front_height(lens) > 0 )
{
assign( rad_up=(lens_rad(lens)*lens_rad(lens)+lens_front_height(lens)*lens_front_height(lens))/(2*lens_front_height(lens)) )
{
translate( [0,0,lens_rim_thickness(lens)/2] )
intersection()
{
translate( [0,0,lens_front_height(lens)-rad_up] )
sphere( r=rad_up, center=true, $fn=50 );
cylinder( r=lens_rad(lens), h=lens_front_height(lens) );
}
}
}
//rim
cylinder( h=lens_rim_thickness(lens), r=lens_rad(lens), center=true );
//back
if( lens_back_height(lens) > 0 )
{
assign( rad_up=(lens_rad(lens)*lens_rad(lens)+lens_back_height(lens)*lens_back_height(lens))/(2*lens_back_height(lens)) )
{
translate( [0,0,-lens_rim_thickness(lens)/2] )
intersection()
{
translate( [0,0,-lens_back_height(lens)+rad_up] )
sphere( r=rad_up, center=true, $fn=50 );
translate( [ 0,0, -lens_back_height(lens) ] ) cylinder( r=lens_rad(lens), h=lens_back_height(lens) );
}
}
}
}
}