arc-circumcircle.js

total 0
used 0
limit 0
/* --- title: Arc Angle categories: arc angles files: head stroke ../point_src/point-content.js pointlist point ../point_src/protractor.js mouse dragging ../point_src/functions/clamp.js stage ../point_src/angle.js ../point_src/text/label.js ../point_src/arc.js ../point_src/protractor.js */ // aa = new Angle(20, 'tau') // ab = new Angle(20).tau class MainStage extends Stage { canvas='playspace' mounted(){ this.centerPoint = new Point({x:200, y:150, radius: 20, color: '#666'}) this.fromPoint = new Point({x:100, y:300}) this.toPoint = new Point({x:350, y:150}) this.dragging.addPoints(this.centerPoint, this.fromPoint, this.toPoint) } draw(ctx){ this.clear(ctx) ctx.fillStyle = '#555' ctx.strokeStyle = 'orange' this.centerPoint.pen.indicator(ctx) // this.centerPoint.pen.line(ctx, undefined, 'red') this.fromPoint.pen.indicator(ctx, {color: 'red'}) this.toPoint.pen.indicator(ctx) this.drawF(ctx) } drawF(ctx){ let res = getArcCenter(this.fromPoint, this.toPoint, this.centerPoint) let c = Point.from(res) // c.pen.indicator(ctx) // penArcPlot(arcPlot, ctx, 'red') let arcPlot = arcFromTo(c, this.fromPoint, this.toPoint) penArcPlot(arcPlot, ctx, 'orange') let arcPlot2 = arcFromTo(c, this.fromPoint, this.toPoint, 1) penArcPlot(arcPlot2, ctx, 'purple') Point.from(res).update({radius: 4}).pen.fill(ctx) // drawArcPlot(arcPlot, ctx, 'orange') } } function getArcCenter(A, B, C) { /* the circumcircle, draw an arc that fits all three. */ const D = 2 * (A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y)); if (D === 0) return null; // points are colinear; no circle const Ux = ( ((A.x ** 2 + A.y ** 2) * (B.y - C.y) + (B.x ** 2 + B.y ** 2) * (C.y - A.y) + (C.x ** 2 + C.y ** 2) * (A.y - B.y)) / D ); const Uy = ( ((A.x ** 2 + A.y ** 2) * (C.x - B.x) + (B.x ** 2 + B.y ** 2) * (A.x - C.x) + (C.x ** 2 + C.y ** 2) * (B.x - A.x)) / D ); return { x: Ux, y: Uy, radius: Math.hypot(A.x - Ux, A.y - Uy)}; } ;stage = MainStage.go();
Run
Meta Data
title Arc Angle
imports ()
files ('head', 'stroke', '../point_src/point-content.js', 'pointlist', 'point', '../point_src/protractor.js', 'mouse', 'dragging', '../point_src/functions/clamp.js', 'stage', '../point_src/angle.js', '../point_src/text/label.js', '../point_src/arc.js', '../point_src/protractor.js')
unused_keys ()
unknown_keys ('categories',)
categories ['', 'arc', 'angles']
filepath_exists True
path arc-circumcircle.js
filepath arc-circumcircle.js
clean_files ('../point_src/core/head.js', '../point_src/setunset.js', '../point_src/stroke.js', '../point_src/compass.js', '../point_src/center.js', '../point_src/point-content.js', '../point_src/pointlistdraw.js', '../point_src/pointlistgradient.js', '../point_src/pointlistshape.js', '../point_src/pointlistgenerator.js', '../point_src/unpack.js', '../point_src/pointlist.js', '../point_src/pointlistpen.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/relative-xy.js', '../point_src/pointcast.js', '../point_src/point.js', '../point_src/protractor.js', '../point_src/events.js', '../point_src/automouse.js', '../point_src/functions/clamp.js', '../point_src/distances.js', '../point_src/text/beta.js', '../point_src/dragging.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/angle.js', '../point_src/text/label.js', '../point_src/arc.js')
markdown {'html': '', 'content': '---\ntitle: Arc Angle\ncategories:\n arc\n angles\nfiles:\n head\n stroke\n ../point_src/point-content.js\n pointlist\n point\n ../point_src/protractor.js\n mouse\n dragging\n ../point_src/functions/clamp.js\n stage\n ../point_src/angle.js\n ../point_src/text/label.js\n ../point_src/arc.js\n ../point_src/protractor.js'}