zoukankan      html  css  js  c++  java
  • 零点

    1 ---
    2 > id: parabola
    3 
    4     x-coordinate-system(x-axis="-5,5,1" y-axis="-3,5,1")
    5 
    6 {.text-center} `y =`${a}{a|1|-5,5,0.1} `x^2+`${b}{b|0|-5,5,0.1} `x+`${c}{c|0|-5,5,0.1}
    contents.md

    import {CoordinateSystem, Step} from '../shared/types';
    
    
    function q(a: number, b: number, c: number) {
      return (x: number) => (a * x * x + b * x + c);
    }
    
    
    function zeros(a: number, b: number, c: number) {
      const disc = b * b - 4 * a * c;
      if (disc < 0) return [];
    
      if (nearlyEquals(disc, 0, 0.1)) return [-b / (2 * a)];
    
      const x1 = (-b + Math.sqrt(disc)) / (2 * a);
      const x2 = (-b - Math.sqrt(disc)) / (2 * a);
      return [x1, x2];
    }
    
    
    export function parabola($step: Step) {
      const $chart = $step.$('x-coordinate-system') as CoordinateSystem;
    
      $step.model.watch((s: any) => {
        const fn = q(s.a, s.b, s.c);
        $chart.setFunctions(fn);
        $chart.drawPoints(zeros(s.a, s.b, s.c).map(p => new Point(p, fn(p))));
      });
    }
  • 相关阅读:
    CSUFT 1002 Robot Navigation
    CSUFT 1003 All Your Base
    Uva 1599 最佳路径
    Uva 10129 单词
    欧拉回路
    Uva 10305 给任务排序
    uva 816 Abbott的复仇
    Uva 1103 古代象形文字
    Uva 10118 免费糖果
    Uva 725 除法
  • 原文地址:https://www.cnblogs.com/wangshixi12/p/12423828.html
Copyright © 2011-2022 走看看