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))));
      });
    }
  • 相关阅读:
    面向对象的相关知识
    模块的导入
    正怎表达式在爬虫里的应用
    前端~css
    CSS知识点
    初识Html
    Python之路--协程/IO多路复用
    进程
    锁 和 线程池
    操作系统-并发-线程-进程
  • 原文地址:https://www.cnblogs.com/wangshixi12/p/12423828.html
Copyright © 2011-2022 走看看