Some code sample for 2d-point

import cv2
import numpy as np
from PIL import Image, ImageDraw

class Point2D(object):
	def __init__(self, x=0., y=0.):
		self.x = x
		self.y = y

	@property
	def x(self):
		return self._x

	@x.setter
	def x(self, value):
		self._x = value

	@property
	def y(self):
		return self._y

	@y.setter
	def y(self, value):
		self._y = value

	def __str__(self):
		return '(X:{}, Y:{})'.format(self.x, self.y)

	def __repr__(self):
		return 'Point({}, {})'.format(self.x, self.y)

	def slope(self, target):
		#k = y2-y1/x2-x1
		try:
			return (target.y - self.y) / (target.x - self.x)
		except ZeroDivisionError:
			return None

	def y_segment(self, target):
		k = self.slope(target)
		return self.y - k * self.x

	def line_function(self, target):

		k = self.slope(target)
		b = self.y_segment(target)
		if k:
			# y = k*x+b
			def fn(x):
				return k * x + b

		else:
			# if k=None -> k is infinity
			def fn(x):

p1 = Point2D(1., -18.9)
p2 = Point2D(1., -17.)
p3 = Point2D(1., -13.)
fn_x = p1.line_function(p2)

if p3.y == fn_x(p3.x):
	print('Belongs to line')
Advertisements

MayaCharm

I love working with PyCharm IDE. One time few of my friends had suggested this IDE for work, and after getting used the configuration and setup i now cannot imagine working with something else…. However, for long time i had been having hard time setting up a production environment on my machines, due to long and exhausting process of conflagration… Until recently when on one of the tech-art forums i came about one post, linking to a wonderful plugin developed by Chris Cunningham. Thank you!

MayaCharm – is a great plugin for PyCharm IDE.

Python and VENV

When working with virtual env for python, some modules may not be found. I had ran into a problem where i was using a simple UI created using standard TkInter module, but when i tested my script on various python versions it gave me an error, reporting that Tcl was not properly installed. A solution for this was to update the  “activate”or”Activate.bat” for windows file and add “set "TCL_LIBRARY=PATH_TO_TCL" " located in the original install of the python version i was using.

Similar workflow should be used to help set additional pointer to other missing components.

referencing from Stackoverflow

Windows 10 + Cortana search problem

This new laptop i have is showing off its great potential for mobile work, including heavy 3D!

Now, i had ran into one problem with Windows10, which is super annoying…. When you press the” Windows button” and type the name of the program you want to run, search does not show any results. After a few minutes of google, i found solution on the superuser.com

Simple POWERSHELL command:

Get-AppXPackage -Name Microsoft.Windows.Cortana | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}

 

A little bit from history, and wiki

Hey, so i am doing some research regarding proper date conversion from excel to python datetime object and had found myself digging deeper and deeper into explanations of how Julian day system works, what it means and how it is translated into today, there a quote that had made itself quite interesting to me:

Julian days begin at noon because when Herschel recommended them, the astronomical day began at noon. The astronomical day had begun at noon ever since Ptolemy chose to begin the days in his astronomical periods at noon. He chose noon because the transit of the Sun across the observer’s meridian occurs at the same apparent time every day of the year, unlike sunrise or sunset, which vary by several hours.

See more: WIKI>Julian_day