Skip to content

Commit

Permalink
secBuildH, secFlatBar, secPipe, secRoundBarについても配列出力に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
st-func committed Feb 25, 2024
1 parent ae106de commit eac03b8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 40 deletions.
76 changes: 44 additions & 32 deletions src/functions/functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,57 @@ test("SecBuildBox", () => {
});

test("SecBuildH", () => {
expect(secBuildH("A", 1200, 400, 19, 25)).toBe(41850.0);
expect(secBuildH("ZY", 1200, 400, 19, 25)).toBeCloseTo(15520364.5833333, 7);
expect(secBuildH("ZZ", 1200, 400, 19, 25)).toBeCloseTo(1336619.9375, 8);
expect(secBuildH("m", 1200, 400, 19, 25)).toBe(328.5225);
expect(secBuildH("iY", 1200, 400, 19, 25)).toBeCloseTo(471.714095162177, 12);
expect(secBuildH("iZ", 1200, 400, 19, 25)).toBeCloseTo(79.9229000487988, 13);
expect(secBuildH("IY", 1200, 400, 19, 25)).toBeCloseTo(9312218750.0, 5);
expect(secBuildH("IZ", 1200, 400, 19, 25)).toBeCloseTo(267323987.5, 6);
const testCases: [string, number][] = [
["A", 41850.0],
["ZY", 15520364.5833333],
["ZZ", 1336619.9375],
["m", 328.5225],
["iY", 471.714095162177],
["iZ", 79.9229000487988],
["IY", 9312218750.0],
["IZ", 267323987.5],
];
verifySecProperty(testCases, (propertyTypes: string[][]) => secBuildH(propertyTypes, 1200, 400, 19, 25));
});

test("secFlatBar", () => {
expect(secFlatBar("A", 100, 19)).toBeCloseTo(1.9e3, 9);
expect(secFlatBar("ZY", 100, 19)).toBeCloseTo(3.16666666666667e4, 8);
expect(secFlatBar("ZZ", 100, 19)).toBeCloseTo(6.01666666666667e3, 9);
expect(secFlatBar("m", 100, 19)).toBeCloseTo(1.4915e1, 11);
expect(secFlatBar("iY", 100, 19)).toBeCloseTo(2.88675134594813e1, 11);
expect(secFlatBar("iZ", 100, 19)).toBeCloseTo(5.48482755730145, 12);
expect(secFlatBar("IY", 100, 19)).toBeCloseTo(1.58333333333333e6, 6);
expect(secFlatBar("IZ", 100, 19)).toBeCloseTo(5.71583333333333e4, 8);
const testCases: [string, number][] = [
["A", 1.9e3],
["ZY", 3.16666666666667e4],
["ZZ", 6.01666666666667e3],
["m", 1.4915e1],
["iY", 2.88675134594813e1],
["iZ", 5.48482755730145],
["IY", 1.58333333333333e6],
["IZ", 5.71583333333333e4],
];
verifySecProperty(testCases, (propertyTypes: string[][]) => secFlatBar(propertyTypes, 100, 19));
});

test("secPipe", () => {
expect(secPipe("A", 508, 9)).toBeCloseTo(1.41088926072718e4, 8);
expect(secPipe("ZY", 508, 9)).toBeCloseTo(1.72946416752188e6, 6);
expect(secPipe("ZZ", 508, 9)).toBeCloseTo(1.72946416752188e6, 6);
expect(secPipe("m", 508, 9)).toBeCloseTo(1.10754806967083e2, 10);
expect(secPipe("iY", 508, 9)).toBeCloseTo(1.76451834787854e2, 10);
expect(secPipe("iZ", 508, 9)).toBeCloseTo(1.76451834787854e2, 10);
expect(secPipe("IY", 508, 9)).toBeCloseTo(4.39283898550558e8, 4);
expect(secPipe("IZ", 508, 9)).toBeCloseTo(4.39283898550558e8, 4);
const testCases: [string, number][] = [
["A", 1.41088926072718e4],
["ZY", 1.72946416752188e6],
["ZZ", 1.72946416752188e6],
["m", 1.10754806967083e2],
["iY", 1.76451834787854e2],
["iZ", 1.76451834787854e2],
["IY", 4.39283898550558e8],
["IZ", 4.39283898550558e8],
];
verifySecProperty(testCases, (propertyTypes: string[][]) => secPipe(propertyTypes, 508, 9));
});

test("secRoundBar", () => {
expect(secRoundBar("A", 32)).toBeCloseTo(8.04247719318987e2, 10);
expect(secRoundBar("ZY", 32)).toBeCloseTo(3.21699087727595e3, 9);
expect(secRoundBar("ZZ", 32)).toBeCloseTo(3.21699087727595e3, 9);
expect(secRoundBar("m", 32)).toBeCloseTo(6.31334459665405, 12);
expect(secRoundBar("iY", 32)).toBeCloseTo(8.0, 12);
expect(secRoundBar("iZ", 32)).toBeCloseTo(8.0, 12);
expect(secRoundBar("IY", 32)).toBeCloseTo(5.14718540364152e4, 8);
expect(secRoundBar("IZ", 32)).toBeCloseTo(5.14718540364152e4, 8);
const testCases: [string, number][] = [
["A", 8.04247719318987e2],
["ZY", 3.21699087727595e3],
["ZZ", 3.21699087727595e3],
["m", 6.31334459665405],
["iY", 8.0],
["iZ", 8.0],
["IY", 5.14718540364152e4],
["IZ", 5.14718540364152e4],
];
verifySecProperty(testCases, (propertyTypes: string[][]) => secRoundBar(propertyTypes, 32));
});
16 changes: 8 additions & 8 deletions src/functions/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ export function secBuildBox(propertyType: string[][], a: number, b: number, t1:
* @param t2 フランジ厚 t2
* @returns 断面性能
*/
export function secBuildH(propertyType: string, a: number, b: number, t1: number, t2: number): number {
export function secBuildH(propertyType: string[][], a: number, b: number, t1: number, t2: number): number[][] {
const secBuildH: SecBuildH = new SecBuildH();
secBuildH.setDimensions(Unit.input(a, "mm"), Unit.input(b, "mm"), Unit.input(t1, "mm"), Unit.input(t2, "mm"));
return getSecSteelProperty(propertyType, secBuildH);
return getSecSteelPropertys(propertyType, secBuildH);
}

/**
Expand All @@ -125,10 +125,10 @@ export function secBuildH(propertyType: string, a: number, b: number, t1: number
* @param t 板厚 t
* @returns 断面性能
*/
export function secFlatBar(propertyType: string, b: number, t: number): number {
export function secFlatBar(propertyType: string[][], b: number, t: number): number[][] {
const secFlatBar: SecFlatBar = new SecFlatBar();
secFlatBar.setDimensions(Unit.input(b, "mm"), Unit.input(t, "mm"));
return getSecSteelProperty(propertyType, secFlatBar);
return getSecSteelPropertys(propertyType, secFlatBar);
}

/**
Expand All @@ -139,10 +139,10 @@ export function secFlatBar(propertyType: string, b: number, t: number): number {
* @param t 板厚 t
* @returns 断面性能
*/
export function secPipe(propertyType: string, d: number, t: number): number {
export function secPipe(propertyType: string[][], d: number, t: number): number[][] {
const secPipe: SecPipe = new SecPipe();
secPipe.setDimensions(Unit.input(d, "mm"), Unit.input(t, "mm"));
return getSecSteelProperty(propertyType, secPipe);
return getSecSteelPropertys(propertyType, secPipe);
}

/**
Expand All @@ -152,8 +152,8 @@ export function secPipe(propertyType: string, d: number, t: number): number {
* @param r 直径 R
* @returns 断面性能
*/
export function secRoundBar(propertyType: string, r: number): number {
export function secRoundBar(propertyType: string[][], r: number): number[][] {
const secRoundBar: SecRoundBar = new SecRoundBar();
secRoundBar.setDimensions(Unit.input(r, "mm"));
return getSecSteelProperty(propertyType, secRoundBar);
return getSecSteelPropertys(propertyType, secRoundBar);
}

0 comments on commit eac03b8

Please sign in to comment.