Skip to content

Commit

Permalink
Better re calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
monman53 committed Jul 1, 2024
1 parent d79aa87 commit 9232100
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Canvas.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { watch, onMounted, ref} from 'vue'
import { watch, onMounted, ref } from 'vue'
import { state, lights, lensGroups, sensor, sensorData, apple, options, style, infR, lensesSorted, lensRs, lensFs, body, lensFronts, aperture, lensBacks } from './globals'
import { Vec, vec, vecRad, getIntersectionLens, crossAngle, fGaussian, intersectionSS, intersectionX, intersectionY, calcLensNWavelength } from './math'
Expand Down
25 changes: 11 additions & 14 deletions src/SVG/Lens.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed } from 'vue'
import { sensor, options, maxLightX, calcLensInfo } from '../globals'
import { sensor, options, maxLightX, calcLensInfo } from '../globals'
import { vec, calcRMax, calcLensFront, calcLensBack } from '../math'
import { setMoveHandler, preventDefaultAndStopPropagation, getPositionOnSvg, getPositionDiffOnSvgApp } from '../handlers'
import type { Lens } from '../type'
Expand Down Expand Up @@ -277,18 +277,15 @@ const apertureSizeChangeStartHandler = (e: any) => {
</g>

<!-- Aperture -->
<g v-if="options.aperture">
<WithBackground>
<!-- Lines -->
<g class="stroke-white normal no-pointer-events">
<line :x1="xm" :y1="-r" :x2="xm" :y2="-r * lens.aperture"></line>
<line :x1="xm" :y1="r" :x2="xm" :y2="r * lens.aperture"></line>
</g>
</WithBackground>
<!-- UI -->
<CircleUI :c="vec(xm, r * lens.aperture)" @mousedown="apertureSizeChangeStartHandler"
class="vertical-resize">
</CircleUI>
</g>
<WithBackground>
<!-- Lines -->
<g class="stroke-white normal no-pointer-events">
<line :x1="xm" :y1="-r" :x2="xm" :y2="-r * lens.aperture"></line>
<line :x1="xm" :y1="r" :x2="xm" :y2="r * lens.aperture"></line>
</g>
</WithBackground>
<!-- UI -->
<CircleUI :c="vec(xm, r * lens.aperture)" @mousedown="apertureSizeChangeStartHandler" class="vertical-resize">
</CircleUI>
</g>
</template>
9 changes: 9 additions & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@ export const globalLensRe = computed(() => {
}
params.push({ f, r, x })
})
// Body
if (!options.value.lensIdeal) {
lensFronts.value.forEach((front, idx) => {
params.push({ f: Infinity, r: lensRs.value[idx], x: front })
})
lensBacks.value.forEach((back, idx) => {
params.push({ f: Infinity, r: lensRs.value[idx], x: back })
})
}
// Apertures
if (options.value.aperture) {
params.push({ f: Infinity, r: aperture.value.r, x: aperture.value.x })
Expand Down

0 comments on commit 9232100

Please sign in to comment.