GithubHelp home page GithubHelp logo

xylophone234 / ruler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from techird/ruler

0.0 2.0 0.0 440 KB

Simple But Powerful Geometry Tool!

Home Page: http://techird.com/ruler

License: MIT License

CSS 4.92% JavaScript 75.97% HTML 19.12%

ruler's Introduction

Ruler.js

强大,在于简单。这是一个简单的尺规作图引擎,可用于几何分析、课件制作、计算坐标等。

类型

尺规作图中需要四种基本的数据结构类型。

  • Number - 数值类型,表示坐标值、距离或索引
  • Point - 表示一个点,其中 xy 属性分别表示横坐标和纵坐标
  • Line - 表示一条直线,给出过该直线的两个点 (x1, y1) 和 (x2, y2),以及 dx = x2 - x1dy = y2 - y1
  • Arc - 表示一个圆的圆弧,给出圆心坐标 (x, y)以及半径 r

API

原子命令从传统的尺规作图中提取,主要包括定点、连线、作弧。基本命令见下表

Command Format Description
define_point pd x y p1 定义一个点 p1,点的坐标为 (x, y)
define_line ld p1 p2 l1 定义一条直线 l1 过点 p1 和点 p2
define_distance dd p1 p2 d1 定义一段距离 d1 表示点 p1 和点 p2 之间的距离
define_arc ad p1 d1 a1 定义圆弧 a1 以 p1 为圆心,d1 为半径
define_arc_2 ad2 p1 p2 a1 定义圆弧 a1 以 p1 为圆心,以 p1 到 p2 之间的距离为半径
define_arc_3 ad3 p1 p2 p3 a1 定义圆弧 a1 以 p1 为圆心,以 p2 到 p3 之间的距离为半径
intersect_arc_arc aai a1 a2 index p1 计算圆弧 a1 和 a2 的交点 p1,交点有两个的时候,index 来选择交点(0 或 1)
intersect_line_arc lai l1 a1 index p1 计算直线 l1 和圆弧 a1 的交点 p1,交点有两个的时候,index 来选择交点(0 或 1)
intersect_line_line lli l1 l2 p1 计算直线 l1 和圆弧 l2 的交点 p1

除此之外,还有内置的拓展命令

Command Format Description
bisector bp p1 p2 m1 定义点 p1 和点 p2 的中点 m1
perpendicular_bisector pbl p1 p2 l1 定义端点为 p1 和 p2 的线段的垂直平分线
perpendicular_line pl l1 p1 l2 过点 p1 作直线 l1 的垂线 l2

ruler's People

Contributors

techird avatar zswang avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.