zoukankan      html  css  js  c++  java
  • fzu 1330:Center of Gravity(计算几何,求扇形重心)

    Problem 1330 Center of Gravity

    Accept: 443    Submit: 830
    Time Limit: 1000 mSec    Memory Limit : 32768 KB

     Problem Description

    Given a sector of radius R, central angle P. You are to calculate the distance between the center of gravity and the center of the circle.

     Input

    Given a sector of radius R, central angle P. You are to calculate the distance between the center of gravity and the center of the circle.

     Output

    Given a sector of radius R, central angle P. You are to calculate the distance between the center of gravity and the center of the circle.

     Sample Input

    0.01 6.28

     Sample Output

    0.000003

     
      计算几何,求扇形的重心
      看的教程里有求扇形重心的公式,我就直接拿来用了:
      
      
      可以看出,这里求的重心位置是重心到圆心的距离,正好是这道题求得值。
      代码
     1 #include <stdio.h>
     2 #include <math.h>
     3 int main()
     4 {
     5     double r,p;
     6     while(scanf("%lf%lf",&r,&p)!=EOF){
     7         double z;    //扇形重心
     8         p/=2;
     9         // 求扇形重心公式一
    10         //double b = r*sin(p);    //圆心角对应的弦长
    11         //double s = p*r;        //圆心角对应的弧长
    12         //z = 2*r*b/(3*s);
    13         //公式二
    14         z = 2*r*sin(p)/(3*p);
    15         printf("%lf
    ",z);
    16     }
    17     return 0;
    18 }

       PS:公式一是公式二的推导后的公式。

     

    Freecode : www.cnblogs.com/yym2013

  • 相关阅读:
    opencv3.2.0形态学滤波之腐蚀
    Ubuntu下卸载QT5.7.1再重装
    opencv3.2.0形态学滤波之膨胀
    Direct3D中的绘制
    绘制流水线
    初始化Direct3D
    VS2012添加对DirectX SDK中需要文件的引用
    ASCII,Unicode 和通用方式
    对话框访问的7种方式【孙鑫老师教程】
    函数指针
  • 原文地址:https://www.cnblogs.com/yym2013/p/3654778.html
Copyright © 2011-2022 走看看