圆的面积公式推导edit icon

Fork(复制)
下载
嵌入
设置
BUG反馈
index.html
现在支持上传本地图片了!
            
            <!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>圆的面积教学工具</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            line-height: 1.6;
            color: #333;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            padding: 20px;
            overflow-x: hidden;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        header {
            text-align: center;
            margin-bottom: 30px;
        }
        h1 {
            color: #2c3e50;
            margin-bottom: 10px;
            font-size: 2.5rem;
        }
        .subtitle {
            color: #7f8c8d;
            font-size: 1.2rem;
        }
        .main-content {
            display: flex;
            flex-wrap: wrap;
            gap: 30px;
            justify-content: center;
        }
        .circle-container {
            flex: 1;
            min-width: 300px;
            max-width: 500px;
            background: white;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            padding: 20px;
            text-align: center;
        }
        #circle-wrapper {
            width: 240px;
            height: 240px;
            margin: 20px auto;
            position: relative;
        }
        #circle {
            width: 100%;
            height: 100%;
            position: relative;
            border-radius: 50%;
            background: #e0e0e0;
            box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
        }
        .sector {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            transform-origin: center;
            cursor: grab;
            transition: transform 0.3s ease;
        }
        .sector:hover {
            filter: brightness(1.1);
        }
        .sector.dragging {
            cursor: grabbing;
            z-index: 100;
            filter: brightness(1.2);
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
        }
        .instructions {
            flex: 1;
            min-width: 300px;
            max-width: 600px;
            background: white;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            padding: 25px;
        }
        h2 {
            color: #3498db;
            margin-bottom: 15px;
            border-bottom: 2px solid #eee;
            padding-bottom: 10px;
        }
        p {
            margin-bottom: 15px;
        }
        .controls {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-top: 20px;
            flex-wrap: wrap;
        }
        button {
            padding: 12px 25px;
            border: none;
            border-radius: 50px;
            background: #3498db;
            color: white;
            font-size: 1rem;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        button:hover {
            background: #2980b9;
            transform: translateY(-2px);
            box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
        }
        .formula {
            background: #f8f9fa;
            padding: 15px;
            border-radius: 10px;
            margin: 20px 0;
            text-align: center;
            font-size: 1.2rem;
            border-left: 4px solid #3498db;
        }
        .highlight {
            color: #e74c3c;
            font-weight: bold;
        }
        footer {
            text-align: center;
            margin-top: 40px;
            color: #7f8c8d;
            font-size: 0.9rem;
        }
        .rotation-info {
            margin-top: 15px;
            font-size: 0.9rem;
            color: #7f8c8d;
        }
        .rotation-controls {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-top: 15px;
        }
        .rot-btn {
            padding: 8px 15px;
            font-size: 0.9rem;
        }
        @media (max-width: 768px) {
            .main-content {
                flex-direction: column;
                align-items: center;
            }
            .circle-container, .instructions {
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>圆的面积公式推导</h1>
            <p class="subtitle">通过分割和重组圆形来理解面积公式</p>
        </header>

        <div class="main-content">
            <div class="circle-container">
                <h2>圆形分割演示</h2>
                <div id="circle-wrapper">
                    <div id="circle">
                        <!-- 扇形将通过JavaScript动态生成 -->
                    </div>
                </div>
                <div class="controls">
                    <button id="resetBtn">重置圆形</button>
                </div>
                <div class="rotation-controls">
                    <button class="rot-btn" id="rotateAllLeft">全部左转10°</button>
                    <button class="rot-btn" id="rotateAllRight">全部右转10°</button>
                </div>
                <p class="rotation-info">提示:可以拖动每个扇形到任意位置,点击扇形可旋转10°</p>
            </div>

            <div class="instructions">
                <h2>教学说明</h2>
                <p>这个交互式工具有助于理解圆的面积公式推导过程:</p>
                
                <div class="formula">
                    圆的面积 = π × r²
                </div>

                <p>1. 将一个圆平均分成16个相等的扇形。</p>
                <p>2. 将这些扇形重新排列,可以组合成一个近似长方形。</p>
                <p>3. 这个近似长方形的长度大约是圆周长的一半(πr),宽度大约是圆的半径(r)。</p>
                <p>4. 因此,圆的面积可以近似为:πr × r = πr²。</p>

                <h2>操作指南</h2>
                <p>• <span class="highlight">拖动</span>:点击并拖动每个扇形到页面任意位置</p>
                <p>• <span class="highlight">旋转</span>:点击扇形可以将其旋转10度</p>
                <p>• <span class="highlight">批量旋转</span>:使用按钮可以同时旋转所有扇形</p>
                <p>• 使用重置按钮可以恢复圆形</p>

                <div class="formula">
                    分割越多,近似程度越高!
                </div>
            </div>
        </div>

        <footer>
            <p>圆的面积教学工具 &copy; 2023 | 设计用于数学教育</p>
        </footer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const circle = document.getElementById('circle');
            const resetBtn = document.getElementById('resetBtn');
            const rotateAllLeftBtn = document.getElementById('rotateAllLeft');
            const rotateAllRightBtn = document.getElementById('rotateAllRight');
            const sectors = [];
            const sectorCount = 16;
            const radius = 120; // 圆的半径
            const center = { x: radius, y: radius }; // 圆心坐标
            
            // 创建扇形
            function createSectors() {
                circle.innerHTML = '';
                sectors.length = 0;
                
                for (let i = 0; i < sectorCount; i++) {
                    const sector = document.createElement('div');
                    sector.className = 'sector';
                    sector.dataset.index = i;
                    sector.dataset.rotation = 0;
                    
                    // 计算扇形角度
                    const startAngle = (i * 2 * Math.PI) / sectorCount;
                    const endAngle = ((i + 1) * 2 * Math.PI) / sectorCount;
                    
                    // 设置扇形样式
                    sector.style.clipPath = generateClipPath(startAngle, endAngle);
                    sector.style.backgroundColor = getColor(i);
                    
                    // 添加事件监听器
                    sector.addEventListener('click', rotateSector);
                    sector.addEventListener('mousedown', startDrag);
                    
                    circle.appendChild(sector);
                    sectors.push({
                        element: sector,
                        startAngle: startAngle,
                        endAngle: endAngle,
                        x: 0,
                        y: 0,
                        rotation: 0,
                        originalPosition: true
                    });
                }
            }
            
            // 生成扇形的clip-path
            function generateClipPath(startAngle, endAngle) {
                // 计算扇形的起点和终点坐标
                const x1 = center.x + radius * Math.cos(startAngle);
                const y1 = center.y + radius * Math.sin(startAngle);
                const x2 = center.x + radius * Math.cos(endAngle);
                const y2 = center.y + radius * Math.sin(endAngle);
                
                // 判断是否大于半圆
                const largeArcFlag = (endAngle - startAngle) <= Math.PI ? 0 : 1;
                
                return `path('M ${center.x} ${center.y} L ${x1} ${y1} A ${radius} ${radius} 0 ${largeArcFlag} 1 ${x2} ${y2} Z')`;
            }
            
            // 获取颜色
            function getColor(index) {
                const hue = (index * 360 / sectorCount) % 360;
                return `hsl(${hue}, 80%, 65%)`;
            }
            
            // 旋转单个扇形 (每次10度)
            function rotateSector(e) {
                // 防止拖动时触发旋转
                if (e.target.classList.contains('dragging')) return;
                
                const sector = e.target;
                const index = parseInt(sector.dataset.index);
                const rotation = (parseInt(sector.dataset.rotation) + 10) % 360;
                
                sector.dataset.rotation = rotation;
                sector.style.transform = `translate(${sectors[index].x}px, ${sectors[index].y}px) rotate(${rotation}deg)`;
                sectors[index].rotation = rotation;
                
                e.stopPropagation();
            }
            
            // 旋转所有扇形
            function rotateAll(degrees) {
                sectors.forEach((sectorData, index) => {
                    const rotation = (parseInt(sectorData.element.dataset.rotation) + degrees) % 360;
                    
                    sectorData.element.dataset.rotation = rotation;
                    sectorData.element.style.transform = `translate(${sectorData.x}px, ${sectorData.y}px) rotate(${rotation}deg)`;
                    sectorData.rotation = rotation;
                });
            }
            
            // 开始拖动
            function startDrag(e) {
                if (e.button !== 0) return; // 只响应左键
                
                const sector = e.target;
                const index = parseInt(sector.dataset.index);
                const sectorData = sectors[index];
                
                // 标记为拖动状态
                sector.classList.add('dragging');
                
                // 保存初始位置
                const startX = e.clientX;
                const startY = e.clientY;
                const initialX = sectorData.x;
                const initialY = sectorData.y;
                
                // 拖动函数
                function drag(e) {
                    const dx = e.clientX - startX;
                    const dy = e.clientY - startY;
                    
                    sectorData.x = initialX + dx;
                    sectorData.y = initialY + dy;
                    sectorData.originalPosition = false;
                    
                    // 只更新位置,不更新旋转
                    sector.style.transform = `translate(${sectorData.x}px, ${sectorData.y}px) rotate(${sectorData.rotation}deg)`;
                    sector.style.zIndex = 1000;
                }
                
                // 停止拖动
                function stopDrag() {
                    document.removeEventListener('mousemove', drag);
                    document.removeEventListener('mouseup', stopDrag);
                    sector.classList.remove('dragging');
                    sector.style.zIndex = 1;
                }
                
                document.addEventListener('mousemove', drag);
                document.addEventListener('mouseup', stopDrag);
                
                e.preventDefault();
            }
            
            // 重置圆形
            function resetCircle() {
                sectors.forEach(sectorData => {
                    sectorData.x = 0;
                    sectorData.y = 0;
                    sectorData.rotation = 0;
                    sectorData.originalPosition = true;
                    sectorData.element.style.transform = '';
                    sectorData.element.dataset.rotation = 0;
                    sectorData.element.style.zIndex = 1;
                });
            }
            
            // 添加按钮事件监听器
            resetBtn.addEventListener('click', resetCircle);
            rotateAllLeftBtn.addEventListener('click', () => rotateAll(-10));
            rotateAllRightBtn.addEventListener('click', () => rotateAll(10));
            
            // 初始化
            createSectors();
        });
    </script>
</body>
</html>
        
预览
控制台