import type { Geometry, Anchorage } from '../types/design'; export const getBoltCoordinates = (geometry: Geometry, anchorage: Anchorage) => { const bolts: { x: number; y: number }[] = []; const { plateShape, widthZ, lengthX, diameter } = geometry; const { count, layout, edgeDistance } = anchorage; if (layout === 'circular' || plateShape === 'circular') { // Circular pattern const boltCircleRadius = (plateShape === 'circular' ? diameter : Math.min(widthZ, lengthX)) / 2 - edgeDistance; for (let i = 0; i < count; i++) { const angle = (2 * Math.PI * i) / count; bolts.push({ x: boltCircleRadius * Math.cos(angle), y: boltCircleRadius * Math.sin(angle), }); } } else { // Rectangular pattern (Matrix) // Simplified: 4 corner bolts for now, or distributed // If count > 4, we distribute them along the edges? // For this MVP, let's assume 4 corners if count=4, or side/end distribution // Let's implement a simple 4-corner + intermediate logic const w = widthZ - 2 * edgeDistance; // Z direction (vertical in plan) const l = lengthX - 2 * edgeDistance; // X direction (horizontal in plan) // Corner bolts bolts.push({ x: l / 2, y: w / 2 }); bolts.push({ x: -l / 2, y: w / 2 }); bolts.push({ x: -l / 2, y: -w / 2 }); bolts.push({ x: l / 2, y: -w / 2 }); // If more bolts, add intermediate (simplified) if (count > 4) { // const remaining = count - 4; // Add to sides... logic can be complex, keeping it simple for MVP } } return bolts; }; export const getIShapePath = (d: number, bf: number, tf: number, tw: number) => { // Returns SVG path string for an I-beam centered at 0,0 // Web is vertical (along Z? No, usually strong axis is X, so web is along X? Wait.) // Standard: Web is along Y (vertical on screen), Flanges are horizontal. // But in structural plan, "Depth d" is usually along the Y-axis (screen), Flange Width bf along X. // Let's assume standard orientation: I shape looks like "I" const h_web = d - 2 * tf; const x_flange = bf / 2; const y_top_flange_bot = h_web / 2; const y_top_flange_top = d / 2; const x_web = tw / 2; // Start top-left of top flange let path = `M ${-x_flange} ${-y_top_flange_top}`; path += ` L ${x_flange} ${-y_top_flange_top}`; // Top edge path += ` L ${x_flange} ${-y_top_flange_bot}`; // Top flange right bottom path += ` L ${x_web} ${-y_top_flange_bot}`; // Web right top path += ` L ${x_web} ${y_top_flange_bot}`; // Web right bottom path += ` L ${x_flange} ${y_top_flange_bot}`; // Bot flange right top path += ` L ${x_flange} ${y_top_flange_top}`; // Bot flange right bottom path += ` L ${-x_flange} ${y_top_flange_top}`; // Bot flange left bottom path += ` L ${-x_flange} ${y_top_flange_bot}`; // Bot flange left top path += ` L ${-x_web} ${y_top_flange_bot}`; // Web left bottom path += ` L ${-x_web} ${-y_top_flange_bot}`; // Web left top path += ` L ${-x_flange} ${-y_top_flange_bot}`; // Top flange left bottom path += ` Z`; return path; };