zoukankan      html  css  js  c++  java
  • hoj1700

    利用点积和叉积列方程

    (x0,y0)X (x1,y1) = sin(120)*R^2     (r为圆的半径)
    (x0,y0) * (x1,y1) = cos(120)*R^2
    结果为:
    x1=b*x0-a*y0;
    a=sin120;
    y1=b*y0+a*x0;   
    b=cos120;

    View Code
    #include <iostream>
    #include
    <cstdio>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cmath>
    using namespace std;

    #define eps 0.0005

    void make(double x0, double y0, double &x1, double &y1)
    {
    double a, b;

    a
    = sqrt(3.0) / 2.0;
    b
    = -1 / 2.0;
    x1
    = x0 * b - y0 * a;
    y1
    = y0 * b + x0 * a;
    }

    int main()
    {
    //freopen("D:\\t.txt", "r", stdin);
    int t;
    scanf(
    "%d", &t);
    while (t--)
    {
    double x0, y0, x1, y1, x2, y2;
    scanf(
    "%lf%lf", &x0, &y0);
    make(x0, y0, x1, y1);
    make(x1, y1, x2, y2);
    if (y1 < y2 || abs(y1 - y2) < eps && x1 - x2 < eps)
    {
    swap(y1, y2);
    swap(x1, x2);
    }
    printf(
    "%.3f %.3f %.3f %.3f\n", x2, y2, x1, y1);
    }
    return 0;
    }
  • 相关阅读:
    杨辉三角
    手动实现md5加密
    戳气球
    重构字符串
    四数相加 II
    背包问题 II
    组合总和 IV
    背包问题 V
    背包问题
    Win 10安装Python及环境变量配置
  • 原文地址:https://www.cnblogs.com/rainydays/p/2000574.html
Copyright © 2011-2022 走看看