<commit_before>define (require, exports, module) ->
	Spine = require 'Spine'
	Raphael = require 'Raphael'

	Marker = require 'controllers/Marker'
	{indexOf} = require 'util'
	style = require 'style'

	class AxesMarker extends Marker
		circles: null
		lines: null

		constructor: ->
			super

			points = @annotation.value.points

			@circles = @picker.paper.set(@picker.paper.circle() for p in points)
			@circles.toBack()
			@circles.attr style.circle

			@setupCircleHover()
			@circles.drag @circleDrag, @dragStart

			@lines = @picker.paper.set(@picker.paper.path() for p in points)
			@lines.toBack()
			@lines.attr style.boundingBox

			@annotation.trigger 'change'

		setupCircleHover: =>
			marker = @

			over = ->
				marker.overCircle = @
				@attr style.circle.hover

			out = ->
				@attr style.circle

			# These run in the context of the circle!
			@circles.hover over, out

		render: =>
			super

			{width: w, height: h} = @picker.getSize()

			intersection = @getIntersection()
			@centerCircle.attr
				cx: intersection.x * w
				cy: intersection.y * h

			@centerCircle.attr stroke: style[@annotation.value.species]

			@label.attr
				x: intersection.x * w
				y: intersection.y * h

			points = @annotation.value.points
			for circle, i in @circles
				circle.attr
					cx: points[i].x * w
					cy: points[i].y * h

			for line, i in @lines
				line.attr path: @lineBetween @circles[i], @centerCircle

		getIntersection: =>
			points = @annotation.value.points

			grads = [
				(points[0].y - points[1].y) / (points[0].x - points[1].x)
				(points[2].y - points[3].y) / (points[2].x - points[3].x)
			]

			# Check for divide-by-zero errors.
			for grad, i in grads
				if isNaN(grad) or grad is Infinity or grad is -Infinity then grads[i] = 0.001

			interX = ((points[2].y - points[0].y) + (grads[0] * points[0].x - grads[1] * points[2].x)) / (grads[0] - grads[1])
			interY = grads[0] * (interX - points[0].x) + points[0].y

			x: interX, y: interY

		getBoundingPathString: =><commit_msg>Really fix divide-by-zero error, closes #63<commit_after>define (require, exports, module) ->
	Spine = require 'Spine'
	Raphael = require 'Raphael'

	Marker = require 'controllers/Marker'
	{indexOf} = require 'util'
	style = require 'style'

	class AxesMarker extends Marker
		circles: null
		lines: null

		constructor: ->
			super

			points = @annotation.value.points

			@circles = @picker.paper.set(@picker.paper.circle() for p in points)
			@circles.toBack()
			@circles.attr style.circle

			@setupCircleHover()
			@circles.drag @circleDrag, @dragStart

			@lines = @picker.paper.set(@picker.paper.path() for p in points)
			@lines.toBack()
			@lines.attr style.boundingBox

			@annotation.trigger 'change'

		setupCircleHover: =>
			marker = @

			over = ->
				marker.overCircle = @
				@attr style.circle.hover

			out = ->
				@attr style.circle

			# These run in the context of the circle!
			@circles.hover over, out

		render: =>
			super

			{width: w, height: h} = @picker.getSize()

			intersection = @getIntersection()
			@centerCircle.attr
				cx: intersection.x * w
				cy: intersection.y * h

			@centerCircle.attr stroke: style[@annotation.value.species]

			@label.attr
				x: intersection.x * w
				y: intersection.y * h

			points = @annotation.value.points
			for circle, i in @circles
				circle.attr
					cx: points[i].x * w
					cy: points[i].y * h

			for line, i in @lines
				line.attr path: @lineBetween @circles[i], @centerCircle

		getIntersection: =>
			points = @annotation.value.points

			grads = [
				(points[0].y - points[1].y) / ((points[0].x - points[1].x) || 0.00001)
				(points[2].y - points[3].y) / ((points[2].x - points[3].x) || 0.00001)
			]

			interX = ((points[2].y - points[0].y) + (grads[0] * points[0].x - grads[1] * points[2].x)) / (grads[0] - grads[1])
			interY = grads[0] * (interX - points[0].x) + points[0].y

			x: interX, y: interY

		getBoundingPathString: =>
{'fraction_non_alphanumeric': 0.14970819588936818, 'fraction_numerical': 0.014209591474245116, 'mean_word_length': 2.9578313253012047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1356878', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1395, 'n_words': 341}