เอกสารอ้างอิงทางเทคนิคและสูตรคำนวณ
การนำคณิตศาสตร์มาใช้งานอย่างสมบูรณ์
คู่มือการนำไปใช้งาน
หน้านี้แสดงสูตรคำนวณที่คุณสามารถคัดลอกไปใช้ได้ทันที รวมถึงวิธีการคำนวณทีละขั้นตอนสำหรับตัวชี้วัดทั้งหมดใน Swim Analytics โดยคุณสามารถใช้ข้อมูลเหล่านี้ในการนำไปปรับใช้เอง ตรวจสอบความถูกต้อง หรือเพื่อทำความเข้าใจให้ลึกซึ้งยิ่งขึ้น
⚠️ หมายเหตุการนำไปใช้งาน
- เวลาทั้งหมดควรถูกแปลงเป็นหน่วยวินาทีเพื่อใช้ในการคำนวณ
- ความเร็วในการว่ายน้ำ (Pace) จะทำงานแบบผกผัน (ค่า % ยิ่งสูง = ความเร็วในการว่ายยิ่งช้าลง)
- ควรตรวจสอบข้อมูลที่กรอกให้ส่งผลลัพธ์ที่สมเหตุสมผลเสมอ
- จัดการกับกรณีพิเศษต่างๆ (เช่น การหารด้วยศูนย์ หรือค่าที่ติดลบ)
ตัวชี้วัดสมรรถภาพหลัก
ความเร็วขีดจำกัด (Critical Swim Speed - CSS)
สูตรคำนวณ:
CSS (เมตร/วินาที) = (D₂ - D₁) / (T₂ - T₁)
ความเร็ว CSS ต่อ 100 เมตร (วินาที) = (T₄₀₀ - T₂₀₀) / 2
🧪 เครื่องคำนวณแบบโต้ตอบ - ทดสอบสูตรคำนวณ
ความเร็ว CSS ต่อ 100 เมตร:
1:49
ขั้นตอนการคำนวณ:
CSS (เมตร/วินาที) = (400 - 200) / (368 - 150) = 0.917 เมตร/วินาที
Pace/100m = 100 / 0.917 = 109 วินาที = 1:49
CSS (เมตร/วินาที) = (400 - 200) / (368 - 150) = 0.917 เมตร/วินาที
Pace/100m = 100 / 0.917 = 109 วินาที = 1:49
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateCSS(distance1, time1, distance2, time2) {
// แปลงเวลาเป็นวินาทีหากจำเป็น
const t1 = typeof time1 === 'string' ? timeToSeconds(time1) : time1;
const t2 = typeof time2 === 'string' ? timeToSeconds(time2) : time2;
// คำนวณ CSS ในหน่วย เมตร/วินาที
const css_ms = (distance2 - distance1) / (t2 - t1);
// คำนวณ Pace ต่อ 100 เมตร ในหน่วยวินาที
const pace_per_100m = 100 / css_ms;
// แปลงเป็นรูปแบบ mm:ss
const minutes = Math.floor(pace_per_100m / 60);
const seconds = Math.round(pace_per_100m % 60);
return {
css_ms: css_ms,
pace_seconds: pace_per_100m,
pace_formatted: `${minutes}:${seconds.toString().padStart(2, '0')}`
};
}
// ตัวอย่างการใช้งาน:
const result = calculateCSS(200, 150, 400, 368);
// ผลลัพธ์: { css_ms: 0.917, pace_seconds: 109, pace_formatted: "1:49" }
คะแนนความเค้นจากการฝึกซ้อมว่ายน้ำ (Swim Training Stress Score - sTSS)
สูตรคำนวณฉบับสมบูรณ์:
sTSS = (IF³) × ระยะเวลา (ชั่วโมง) × 100
IF = NSS / FTP
NSS = ระยะทางรวม / เวลารวม (เมตร/นาที)
🧪 เครื่องคำนวณแบบโต้ตอบ - ทดสอบสูตรคำนวณ
ค่า sTSS ที่คำนวณได้:
55
ขั้นตอนการคำนวณ:
NSS = 3000 เมตร / 55 นาที = 54.5 เมตร/นาที
FTP = 100 / (93/60) = 64.5 เมตร/นาที
IF = 54.5 / 64.5 = 0.845
sTSS = 0.845³ × (55/60) × 100 = 55
NSS = 3000 เมตร / 55 นาที = 54.5 เมตร/นาที
FTP = 100 / (93/60) = 64.5 เมตร/นาที
IF = 54.5 / 64.5 = 0.845
sTSS = 0.845³ × (55/60) × 100 = 55
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateSTSS(distance, timeMinutes, ftpMetersPerMin) {
// คำนวณความเร็วการว่ายน้ำแบบปรับฐาน (Normalized Swim Speed)
const nss = distance / timeMinutes;
// คำนวณค่าปัจจัยความหนัก (Intensity Factor)
const intensityFactor = nss / ftpMetersPerMin;
// คำนวณชั่วโมง
const hours = timeMinutes / 60;
// คำนวณ sTSS โดยใช้ค่าปัจจัยความหนักยกกำลังสาม
const stss = Math.pow(intensityFactor, 3) * hours * 100;
return Math.round(stss);
}
// ตัวอย่างการใช้งาน:
const stss = calculateSTSS(3000, 55, 64.5);
// ผลลัพธ์: 55
// ตัวช่วย: แปลง CSS เป็น FTP
function cssToFTP(cssPacePer100mSeconds) {
// FTP ในหน่วย เมตร/นาที = 100 เมตร / (Pace ในหน่วยนาที)
return 100 / (cssPacePer100mSeconds / 60);
}
// ตัวอย่าง: CSS 1:33 (93 วินาที)
const ftp = cssToFTP(93); // ผลลัพธ์: 64.5 เมตร/นาที
SWOLF
สูตรคำนวณ:
SWOLF = เวลาต่อรอบ (วินาที) + จำนวนสโตรก
SWOLF₂₅ = (เวลา × 25/ความยาวสระ) + (จำนวนสโตรก × 25/ความยาวสระ)
🧪 เครื่องคำนวณแบบโต้ตอบ - ทดสอบสูตรคำนวณ
ค่า SWOLF:
35
การคำนวณ:
SWOLF = 20 วินาที + 15 สโตรก = 35
SWOLF = 20 วินาที + 15 สโตรก = 35
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateSWOLF(timeSeconds, strokeCount) {
return timeSeconds + strokeCount;
}
function calculateNormalizedSWOLF(timeSeconds, strokeCount, poolLength) {
const normalizedTime = timeSeconds * (25 / poolLength);
const normalizedStrokes = strokeCount * (25 / poolLength);
return normalizedTime + normalizedStrokes;
}
// ตัวอย่าง:
const swolf = calculateSWOLF(20, 15);
// ผลลัพธ์: 35
const swolf50m = calculateNormalizedSWOLF(40, 30, 50);
// ผลลัพธ์: 35 (ปรับฐานเป็นสระ 25 เมตร)
ชีวกลศาสตร์ของสโตรก (Stroke Mechanics)
ความถี่สโตรก (Stroke Rate - SR)
สูตรคำนวณ:
SR = 60 / เวลาครบรอบสโตรก (วินาที)
SR = (จำนวนสโตรก / เวลาเป็นวินาที) × 60
🧪 เครื่องคำนวณแบบโต้ตอบ - ทดสอบสูตรคำนวณ
ความถี่สโตรก (SPM):
72
การคำนวณ:
SR = (30 / 25) × 60 = 72 SPM
SR = (30 / 25) × 60 = 72 SPM
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateStrokeRate(strokeCount, timeSeconds) {
return (strokeCount / timeSeconds) * 60;
}
// ตัวอย่าง:
const sr = calculateStrokeRate(30, 25);
// ผลลัพธ์: 72 SPM
ระยะทางต่อสโตรก (Distance Per Stroke - DPS)
สูตรคำนวณ:
DPS = ระยะทาง / จำนวนสโตรก
DPS = ระยะทาง / (SR / 60)
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateDPS(distance, strokeCount, pushoffDistance = 0) {
const effectiveDistance = distance - pushoffDistance;
return effectiveDistance / strokeCount;
}
// ตัวอย่าง (สระ 25 เมตร, ระยะถีบตัวขอบสระ 5 เมตร):
const dps = calculateDPS(25, 12, 5);
// ผลลัพธ์: 1.67 เมตร/สโตรก
// สำหรับการว่ายหลายรอบ:
const dps100m = calculateDPS(100, 48, 4 * 5);
// ผลลัพธ์: 1.67 เมตร/สโตรก (4 รอบ × ระยะถีบตัว 5 เมตร)
ความเร็วจาก SR และ DPS
สูตรคำนวณ:
ความเร็ว (เมตร/วินาที) = (SR / 60) × DPS
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateVelocity(strokeRate, dps) {
return (strokeRate / 60) * dps;
}
// ตัวอย่าง:
const velocity = calculateVelocity(70, 1.6);
// ผลลัพธ์: 1.87 เมตร/วินาที
ดัชนีสโตรก (Stroke Index - SI)
สูตรคำนวณ:
SI = ความเร็ว (เมตร/วินาที) × DPS (เมตร/สโตรก)
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateStrokeIndex(velocity, dps) {
return velocity * dps;
}
// ตัวอย่าง:
const si = calculateStrokeIndex(1.5, 1.7);
// ผลลัพธ์: 2.55
กราฟบริหารจัดการสมรรถภาพ (Performance Management Chart - PMC)
การคำนวณค่า CTL, ATL และ TSB
สูตรคำนวณ:
CTL วันนี้ = CTL เมื่อวาน + (TSS วันนี้ - CTL เมื่อวาน) × (1/42)
ATL วันนี้ = ATL เมื่อวาน + (TSS วันนี้ - ATL เมื่อวาน) × (1/7)
TSB = CTL เมื่อวาน - ATL เมื่อวาน
ตัวอย่างการเขียน Code ด้วย JavaScript:
function updateCTL(previousCTL, todayTSS) {
return previousCTL + (todayTSS - previousCTL) * (1/42);
}
function updateATL(previousATL, todayTSS) {
return previousATL + (todayTSS - previousATL) * (1/7);
}
function calculateTSB(yesterdayCTL, yesterdayATL) {
return yesterdayCTL - yesterdayATL;
}
// คำนวณ PMC สำหรับชุดการออกกำลังกาย
function calculatePMC(workouts) {
let ctl = 0, atl = 0;
const results = [];
workouts.forEach(workout => {
ctl = updateCTL(ctl, workout.tss);
atl = updateATL(atl, workout.tss);
const tsb = calculateTSB(ctl, atl);
results.push({
date: workout.date,
tss: workout.tss,
ctl: Math.round(ctl * 10) / 10,
atl: Math.round(atl * 10) / 10,
tsb: Math.round(tsb * 10) / 10
});
});
return results;
}
// ตัวอย่างการใช้งาน:
const workouts = [
{ date: '2025-01-01', tss: 50 },
{ date: '2025-01-02', tss: 60 },
{ date: '2025-01-03', tss: 45 },
// ... รายการออกกำลังกายอื่นๆ
];
const pmc = calculatePMC(workouts);
// คืนค่าอาร์เรย์ที่มี CTL, ATL, TSB สำหรับแต่ละวัน
การคำนวณขั้นสูง (Advanced Calculations)
CSS จากหลายระยะทาง (Regression Method)
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateCSSRegression(distances, times) {
// การถดถอยเชิงเส้น (Linear regression): distance = a + b*time
const n = distances.length;
const sumX = times.reduce((a, b) => a + b, 0);
const sumY = distances.reduce((a, b) => a + b, 0);
const sumXY = times.reduce((sum, x, i) => sum + x * distances[i], 0);
const sumXX = times.reduce((sum, x) => sum + x * x, 0);
const slope = (n * sumXY - sumX * sumY) / (n * sumXX - sumX * sumX);
const intercept = (sumY - slope * sumX) / n;
return {
css: slope, // ความเร็วขีดจำกัดในการว่ายน้ำ (เมตร/วินาที)
anaerobic_capacity: intercept // ความจุระยะทางแบบไม่ใช้ออกซิเจน (เมตร)
};
}
// ตัวอย่างที่มีระยะทางทดสอบหลายระยะ:
const distances = [100, 200, 400, 800];
const times = [65, 150, 340, 720]; // หน่วยเป็นวินาที
const result = calculateCSSRegression(distances, times);
// ผลลัพธ์: { css: 1.18, anaerobic_capacity: 15.3 }
ปัจจัยความหนัก (Intensity Factor) จากความเร็ว (Pace)
ตัวอย่างการเขียน Code ด้วย JavaScript:
function calculateIntensityFactor(actualPace100m, thresholdPace100m) {
// แปลง Pace เป็นความเร็ว (เมตร/วินาที)
const actualSpeed = 100 / actualPace100m;
const thresholdSpeed = 100 / thresholdPace100m;
return actualSpeed / thresholdSpeed;
}
// ตัวอย่าง:
const if_value = calculateIntensityFactor(110, 93);
// ผลลัพธ์: 0.845 (การว่ายอยู่ที่ 84.5% ของระดับขีดจำกัด)
การวิเคราะห์ความสม่ำเสมอของความเร็ว (Pace Consistency Analysis)
ตัวอย่างการเขียน Code ด้วย JavaScript:
function analyzePaceConsistency(laps) {
const paces = laps.map(lap => lap.distance / lap.time);
const avgPace = paces.reduce((a, b) => a + b) / paces.length;
const variance = paces.reduce((sum, pace) =>
sum + Math.pow(pace - avgPace, 2), 0) / paces.length;
const stdDev = Math.sqrt(variance);
const coefficientOfVariation = (stdDev / avgPace) * 100;
return {
avgPace,
stdDev,
coefficientOfVariation,
consistency: coefficientOfVariation < 5 ? "ยอดเยี่ยม (Excellent)" :
coefficientOfVariation < 10 ? "ดี (Good)" :
coefficientOfVariation < 15 ? "ปานกลาง (Moderate)" : "แปรปรวน (Variable)"
};
}
// ตัวอย่าง:
const laps = [
{ distance: 100, time: 70 },
{ distance: 100, time: 72 },
{ distance: 100, time: 71 },
// ...
];
const analysis = analyzePaceConsistency(laps);
// ผลลัพธ์: { avgPace: 1.41, stdDev: 0.02, coefficientOfVariation: 1.4, consistency: "ยอดเยี่ยม (Excellent)" }
การตรวจจับความเหนื่อยล้าจากจำนวนสโตรก
ตัวอย่างการเขียน Code ด้วย JavaScript:
function detectFatigue(laps) {
const firstThird = laps.slice(0, Math.floor(laps.length/3));
const lastThird = laps.slice(-Math.floor(laps.length/3));
const firstThirdAvg = firstThird.reduce((sum, lap) =>
sum + lap.strokeCount, 0) / firstThird.length;
const lastThirdAvg = lastThird.reduce((sum, lap) =>
sum + lap.strokeCount, 0) / lastThird.length;
const strokeCountIncrease = ((lastThirdAvg - firstThirdAvg) / firstThirdAvg) * 100;
return {
firstThirdAvg: Math.round(firstThirdAvg * 10) / 10,
lastThirdAvg: Math.round(lastThirdAvg * 10) / 10,
percentIncrease: Math.round(strokeCountIncrease * 10) / 10,
fatigueLevel: strokeCountIncrease < 5 ? "น้อยมาก (Minimal)" :
strokeCountIncrease < 10 ? "ปานกลาง (Moderate)" :
strokeCountIncrease < 20 ? "เห็นได้ชัด (Significant)" : "รุนแรง (Severe)"
};
}
// ตัวอย่าง:
const laps = [
{ strokeCount: 14 }, { strokeCount: 14 }, { strokeCount: 15 },
{ strokeCount: 15 }, { strokeCount: 16 }, { strokeCount: 16 },
{ strokeCount: 17 }, { strokeCount: 18 }, { strokeCount: 18 }
];
const fatigue = detectFatigue(laps);
// ผลลัพธ์: { firstThirdAvg: 14.3, lastThirdAvg: 17.7, percentIncrease: 23.8, fatigueLevel: "รุนแรง (Severe)" }
การตรวจสอบความถูกต้องของข้อมูล (Data Validation)
การตรวจสอบคุณภาพข้อมูลการออกกำลังกาย
ตัวอย่างการเขียน Code ด้วย JavaScript:
function validateWorkoutData(workout) {
const issues = [];
// ตรวจสอบช่วง Pace ที่สมเหตุสมผล (1:00-5:00 ต่อ 100 เมตร)
const avgPace = (workout.totalTime / workout.totalDistance) * 100;
if (avgPace < 60 || avgPace > 300) {
issues.push(`Pace เฉลี่ยผิดปกติ: ${Math.round(avgPace)} วินาทีต่อ 100 เมตร`);
}
// ตรวจสอบจำนวนสโตรกที่สมเหตุสมผล (10-50 ต่อ 25 เมตร)
const avgStrokesPer25m = (workout.totalStrokes / workout.totalDistance) * 25;
if (avgStrokesPer25m < 10 || avgStrokesPer25m > 50) {
issues.push(`จำนวนสโตรกผิดปกติ: ${Math.round(avgStrokesPer25m)} ครั้งต่อ 25 เมตร`);
}
// ตรวจสอบความถี่สโตรกที่สมเหตุสมผล (30-150 SPM)
const avgSR = calculateStrokeRate(workout.totalStrokes, workout.totalTime);
if (avgSR < 30 || avgSR > 150) {
issues.push(`ความถี่สโตรกผิดปกติ: ${Math.round(avgSR)} SPM`);
}
// ตรวจสอบรอบที่ขาดหายไป (ช่วงเวลาที่เว้นว่าง)
if (workout.laps && workout.laps.length > 1) {
for (let i = 1; i < workout.laps.length; i++) {
const gap = workout.laps[i].startTime -
(workout.laps[i-1].startTime + workout.laps[i-1].duration);
if (gap > 300) { // เว้นช่วงเกิน 5 นาที
issues.push(`ตรวจพบช่องว่างขนาดใหญ่ระหว่างรอบที่ ${i} และ ${i+1}`);
}
}
}
return {
isValid: issues.length === 0,
issues: issues
};
}
มาตรฐานการคำนวณที่โปร่งใส
ความถูกต้องแม่นยำคือหัวใจสำคัญของ Swim Analytics เราเปิดเผยสูตรคำนวณและวิธีการทำงานเพื่อให้คุณมั่นใจในข้อมูลที่คุณได้รับจากการฝึกซ้อมทุกครั้ง