Skip to content

Commit

Permalink
add a few doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
tizayi committed Sep 22, 2023
1 parent 4f06b56 commit 60d8d74
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/calculations/qrange.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from "vitest";
import { test } from "vitest";
import { computeQrange } from "./qrange";
import {
BeamlineConfig,
Expand Down Expand Up @@ -39,5 +39,4 @@ test("Test getting q from pixel position ", () => {

const result = computeQrange(detector, beamstop, cameraTube, beamConfig);
console.log(result);
expect(result).toBeTruthy();
});
11 changes: 10 additions & 1 deletion src/calculations/qrange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import {
} from "../utils/types";
import { Vector3, Vector4 } from "three";
import { Ray } from "../calculations/ray";

/**
* Compute the viable and full qranges
* @param detector
* @param beamstop
* @param cameraTube
* @param beamProperties
* @returns
*/
export function computeQrange(
detector: Detector,
beamstop: Beamstop,
Expand All @@ -37,6 +44,8 @@ export function computeQrange(
detector.resolution.height,
);

console.log(t1)

if (t1 != null && cameraTube != null && cameraTube.diameter != 0) {
t1 = t1.intersect(
ray.getCircleIntersectionParameterRange(
Expand Down
6 changes: 5 additions & 1 deletion src/calculations/ray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class Ray {
coeffOfx2 * Math.pow(this.direction.x, 2) +
coeffOfxy * this.direction.x * this.direction.y +
coeffOfy2 * Math.pow(this.direction.y, 2);

const b =
2 * coeffOfx2 * this.direction.x * this.initial_point.x +
coeffOfxy *
Expand All @@ -56,15 +57,18 @@ export class Ray {
2 * coeffOfy2 * this.direction.y * this.initial_point.y +
coeffOfx * this.direction.x +
coeffOfy * this.direction.y;

const c =
coeffOfx2 * Math.pow(this.initial_point.x, 2) +
coeffOfxy * this.initial_point.x * this.initial_point.y +
coeffOfy2 * Math.pow(this.initial_point.y, 2) +
coeffOfx * this.initial_point.x +
coeffOfy * this.initial_point.y +
constant;


console.log("stuff")
const discriminant = Math.pow(b, 2) - 4 * a * c;
console.log(discriminant)
if (discriminant < 0) return null;
if (a == 0) {
if (b == 0)
Expand Down
1 change: 0 additions & 1 deletion src/utils/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const energy2WavelengthConverter = (energy: number): number => {
* @returns
*/
export const wavelength2EnergyConverter = (wavelength: number): number => {
//wavelength in nm
return ((PLANCK * CSPEED) / (wavelength * 1e9)) * 6.242e15;
};

Expand Down

0 comments on commit 60d8d74

Please sign in to comment.