« first day (2805 days earlier)      last day (2368 days later) » 
00:00 - 17:0017:00 - 23:00

00:03
hallo
Cabbage
00:31
cbg guys; I have a quick question: when you have a single class inside of a module that requires an external library, but the rest don't, is it generally good coding practice to run import xxx inside of the constructor of the class?
Or should it be done still @ the top module level, with a try-catch, and another layer of checking during initialization of tokenizer?
01:16
cbg
wim
wim
01:30
It should still be done at the top module level
Without any try/except
If you need to, isolate the code which needs the external dependency from the other stuff (i.e. move it into own module)
hmm okay, gotcha
wim
wim
sometime you need "soft" dependencies like this (and Python packaging allows the installer to do request them with setuptools extras_require) but if the dep is needed and not there then you want the ImportError at startup time (fail early), not at runtime
yes, it's more of an add-on to this module and the bulky good stuff does not require this specific dep
 
4 hours later…
05:34
hello room 6
I'm being drawn toward the dark side day by day. They just code in Java all day here. Please help me.
I've moved almost entirely to C/C++ the last month or so. Not much python at work D:
Still better than Java though
Well. I don't know about C++ but IntelliJ has amazing support for Java. Most of my development consists of typing two characters and then tab completing.
Jetbrains software is very solid all around. For most stuff I use vim, but I can't do web development without webstorm
05:45
I see the appeal in being "old school" by learning ten thousand shortcuts to use either vim or emacs but there's just no hope of being nearly as productive without an IDE
 
1 hour later…
07:13
recbg
@user3483203 nothing can be worse than C++.
May 20 at 7:21, by abarnert
@AnttiHaapala Unless you're talking about pre-ANSI C++, there are two people who understand the language: Andrei Alexandrescu, who hates it, and Herb Sutter, who's paid to not hate it.
cbg-ning
07:40
Cabbage
lacks minimal understanding Too broad stackoverflow.com/questions/50962431/…
 
1 hour later…
08:47
Hi all, I am using currently java ListenableFuture from Guava which supports Futures module where i can combine and chain futures github.com/google/guava/wiki/ListenableFutureExplained. Is there something equivalent for cpu bpund tasks in python. I saw the concurrent.futures module but it looks quite basic and does not have all functionality. Thanks
09:22
is a virtual machine good for deep learning?
good in what terms? performance wise, I'd say no.
09:35
:c
09:56
I'd say definitly no performance wise. I run a VM and it sucks up the ram. It's also painfully slow.
docker FTW!
10:18
Machine learning on docker???
@Simon It's just a container for things. I think it's much better than even your simple setups. e.g. Quick search example github.com/floydhub/dl-docker cc @Neoares
but that's docker :P
Hey I am looking to create a python console application that tails logfiles from programms it has started before .. it should be looking smiliar to docker-compose logs (ibm.com/developerworks/library/mw-1612-grateau-trs/figure03.png) Any ideas to point me in the right direction ?
10:33
@meat Like you said, you might be better off looking how docker-compose logs works. Unless, you have already tried that.
I was thinking this is closed source ! Sorry :)
And it is even written in python @shad0w_wa1k3r thanks !
No problem :)
@meat It's an official library (see github URL - docker/compose), so it is open-sourced like the main docker software.
Also, docker-compose can be installed via pip
10:49
why python?
that's a very broad question. But I'll still answer, why not!?
we're not here to advertise the language
@YouCrackedMeUp because not python
also, hello
 
1 hour later…
11:56
If we have a dupe target for "how come "C:\users\whatever" doesn't parse right?", python error in opening file (codec can't decode bytes in position 2-3), i use spyder needs it
There's stackoverflow.com/questions/2953834/windows-path-in-python, but the only answer that actually explains the problem is sitting at a mere +2
12:10
And one of those two was mine...
The accepted answer doesn't explain the issue because OP seems to have it figured out already.
OPs are the worst
Sort of, yeah. It's still good to explain the problem for all the people who come here from google though.
yep
which is why my only vote on that entire page is on Vaultah's explanation
How many people from Google actually read the question and not just scroll down for answers?
12:14
1 of them is me, so at least 1 (and I can vouch for most of the people here)
My ideal canonical question would have a path that inadvertently has every single escape sequence
C:\users\nathan\reference documents\traffic report\adelaide\back_streets...
unfortunately that question is pretty crap to begin with
@shad0w_wa1k3r I try so that I can vote, but I bet a lot of people don't, especially the lower rep users
"I can't seem to get the directory right"
oh, that's my problem too!
@Simon I suspect most readers aren't even registered
12:17
But any person with just a bit of intelligence will first read the question to see if the answers might apply to their own problem. Now, this doesn't say anything about people on the internet.
TBH if the question isn't a one/two liner I bet a lot of people don't bother...
I rarely read the question. I usually just take a quick glance.
As of late my incentive structure for participating in SO has shifted from "help people with their problems and get rewarded" to "hammer questions before the undeserving are unjustly rewarded"
6
Kevin, aka the mighty Thor
I think a lot of high-rep people are currently going through a phase like that, but maybe that's just my imagination
12:22
^ Agreed
Hmm it bothers me that unicodedata.name("\n") raises a ValueError.
Google tells me "The Unicode Standard does not formally assign control characters" but I'm still salty about it
So much for adding "C:\nathan contains a newline, you fool, look here even unicodedata.name says NEWLINE" to my canonical post
Writing my own extension, get_name = lambda c: "NEWLINE" if c == "\n" else unicodedata.name(c) , lacks that same punchiness
12:37
and you'd have to handle all the escapes you want to discuss
unicodedata.name fails on about 20% of the characters in the 0-255 ordinal range, but besides newline tab and carriage return, they're all \x characters that I don't care much about
Those wouldn't have consistent names across platforms anyway, most likely. Maybe my shell displays 185 as "â•£", but yours displays it as "Ï€"
solution: return a set of all possible names. {'BOX DRAWINGS DOUBLE VERTICAL AND LEFT', 'GREEK SMALL LETTER PI', ...}
Never mind that there are like 65,000 different code pages which might all have different values for 185
13:01
yam it's hot here :(
"32 degrees, feels like 35". Can't wait for tomorrow's promised "16, feels like 15" and the ensuing headache
Guess that's why old people talk about the weather all the time. Am I old now?
Terminology Q: when writing a polynomial like A*X^2 + B*X + C, how should I refer to C, to distinguish it from A and B? The coefficient of smallest... degree?
@AndrasDeak Nah. You're getting there, but you're not quite talking about it "all the time" yet.
The constant term of the polynomial?
I can't say "the third coefficient" because I don't know how many coefficients there are
the coefficient of the lowest degree could work, but that would/could mean B if C=0
13:10
80% chance that Generate random polynom for random input will reply "oh, actually I need to fit an arbitrary number of points, not just one, tee hee"
cbg \o
"I figured I'd just be able to take the answer for one point, and change number_of_points_needing_fitting from 1 to whatever number I require"
How is y = sum(coefficient * a**n for n, coefficient in enumerate(coefficients)) constant time?
... Oops.
not that it matters, OP has 5<n<10 or something, hardly asymptotic
13:21
Well, if it's not constant time, at least there's an upper bound on its runtime, since the degree will be no larger than 10.
Right
You can't trust anything I say in a comment anyway, you may as well fact-check television static
Hmm, speaking of random signals, I worry that OP will reply "This works, but the value of the final coefficient doesn't necessarily lie within the same range that all the other coefficients are in. I need all of them to have the same distribution"
then close as unclear
Bit tricky there since if all of the coefficients are between 1 and 10, then there's simply no solution for, say, f(1) = -100
or if they're between -10 and 10, there's no solution for f(1) = 10**100
You can't do that. But you can constrain the coefficients to be of similar size by doing what I suggested in my comment
you can even constrain your coefficients to be equal, unless you hit a root at A
there are way too many options, which is why I voted too broad
A too-broad question about finding a valid polynomial from an infinite set of valid polynomials. How very meta.
well it's also not really a programming question...
13:28
My train of thought went from "this isn't a programming question, I'll just leave a comment" to "the OP basically understands my comment, but wants to know how to convert it to code, so I guess it's a programming question now"
Hardly a rigorous chain of logic, but you know how I like to throw starfish back into the ocean
Ah. There you go, the problem was OP's blind faith in your comment :P
"How am I supposed to do that in constant time?", they asked :D
It's O(1) with respect to both A and B. two out of three isn't bad ;-)
(assuming arithmetic on arbitrarily large numbers is constant time. Not valid in Nebraska. Ask your doctor if algorithm continues for four or more hours)
Bah, I was going to issue a correction about the complexity, but SO is down for me
works for me
Yeah, refreshing fixed it. I was tricked because the page said "down for maintenance" which made me suspect that it would take longer than one page load to elapse
What's the term for "will definitely not run forever"?
finishes in finite time
13:36
That's not fun. I want an obscure latin term or something.
ah
if there's one I'm unfamiliar with it
brb forging some ancient documents with the term "lemniscatastic" so I can claim that it has some legitimacy
Googling "ends in finite time", found the wikipedia article for "Ultimate fate of the universe". Well that escalated quickly.
re-cbg
13:44
Nothing quick about the ultimate fate of the universe, though. When your timeline includes 10**100 AD, you can afford to stop and smell the roses
I don't know, thinking about the heat death of the universe still gives me a kind of existential dread
@AndrasDeak I was just re-reading that one yesterday, while looking for an appropriate link for a SE Physics comment.
I honestly don't know how cosmologists cope
I've read enough scifi stories where the protagonists reverse the death of the universe, or escape from it, to the extent that I'm optimistic that we'll figure something out in real life.
we sure will :D
13:47
It's a hard problem but we have a googol years to figure out a solution
The OP wanted to know if the ultimate fate was black holes that eventually merged into one. I pointed out they'll evaporate if you wait long enough, and expansion tends to stop them from merging.
You could hang out in a pocket dimension until after the Big Crunch sparks a new Big Bang. You could build a huge AI that hangs out in quantum space and crunches numbers until it figures out how to pull a "Let there be light". You could find the strongest man in existence and make him turn a very heavy crank that pumps negentropy into the dying world. All real examples.
The universe is but a pup. On the timescale where black holes merely start to lose mass from Hawking radiation, the present era is just a stone's throw from the Big Bang.
> you may think it's a long way down the road to the chemist, but that's just peanuts to space.
And by extension, time
Completely unrelated, but I've just noticed the bulletin about the new "ask a question" wizard meta.stackoverflow.com/questions/369682/…
5
13:55
And evaporation via Hawking radiation takes a while. IIRC, your typical stellar mass BH has a radiation temperature around a nanokelvin, and a flux of around 10^-27 watts. The big galactic ones are a thousand times colder.
We just have to figure out how to embed useful calculations in the gravitational interactions of black holes, and then we can extend our deadline by a couple orders of magnitude
@AndrasDeak I'm skeptical, but slightly optimistic. :) But it's nice to see the SO Meta crew giving feedback on it.
yup
if it goes live we'll at least have one more roll of newspaper with which to slap bad askers on the nose
@Simon "How many people from Google actually read the question" Well, before I registered I'd give the question a brief look, to see how relevant it was to my question. But yeah, most people come to SO for the pearls, not the sand, so the question is of limited interest to them.
Looks decent. I'd also like a section on tag info that spelled out how to ask questions for that specific tag (IF any additional details are needed). Wizard would check to see if tags listed had any of those further details and point question asker to that information.
14:02
@piRSquared that wouldn't be maintainable
Who says what is needed for a given tag? What about new tags, new versions, etc...
And it presumes that 1 rep newbies have a clue about proper tag selection.
well the first SO-specific step of the wizard helps choose tags
@AndrasDeak It would be as maintainable as tag info. Tag community contributes to establishing what the norms would be.
@PM2Ring Can't solve every problem /shrug
@piRSquared ¯\_(ツ)_/¯
@PM2Ring I used to avoid SO as much as possible, before I became a member.
14:19
@AndrasDeak For big polynomials, it's probably better to use Horner's method to evaluate it.
Oops. I meant to ping @Kevin with that.
Speaking of astronomical things, Mars is making a close approach, and next month it'll be brighter than it has been since 2003. It's already significantly brighter than it was a month or so ago.
cbg
maybe opportunity will talk to us again then
Yes, I've beaten my previous highest up-voted post by 1. +11 now :)
The other day I posted this IFS fern image. I just made a few improvements to the code, so it's a lot faster (using a Numpy array instead of plotting pixels one by one into a Tkinter PhoroImage), and gives smoother results.
so pretty...
14:32
That's a nice fern.
DSM
DSM
Perennial cabbage for all!
you and Kevin are making me want to learn how to generate images :\
cbg DSM
declined - flags should not be used to indicate technical inaccuracies, or an altogether wrong answer -- what am I misunderstanding about a very low quality flag?
do you have an example of what you tried to flag ?
I can make a fern with the visualizer program I posted yesterday ([[-0.29, 0.0, 0.12], [0.5, -0.12, 0.5], [328, 5, 37], [0.28, 0.91, 0.27]]) but it's not at all pretty because it renders intermediary frames so it's just a riot of mostly irrelevant squares
14:36
@MoxieBall depends on the answer
@AndrasDeak The bottom one here
Yeah, that's not VLQ. That's just wrong.
Also an infographic for "not an answer" for good measure meta.stackoverflow.com/questions/287563/…
DSM
DSM
You call in the police to break up a fight, not to settle the argument about which team is really better.
Thanks, guys. The brightness is a function of how often that pixel got visited by the IFS algorithm. But the very bright points get visited a lot more than the dimmer ones. When I did this stuff on the Amiga I discovered a great logarithmic function that gave really nice results, but unfortunately I can't remember it. I still have my Amiga, but I don't currently have a working monitor for it, so I can't look up that code.
My current code use the hyperbolic tangent to do the scaling, which looks a little nicer than logarithmic scaling.
Can I get an assist? Please run this code and confirm that you get the same results that I've posted on the question I'll link in a bit.
import pandas as pd
import numpy as np

np.random.seed([3, 1415])

n = 100
df = pd.DataFrame(
    np.random.rand(n, 4),
    pd.date_range('2000-01-01', periods=n, name='date'),
    ['ABC','XYZ __', 'One', 'Two Three']
)


def dcorr(df, n):
    return df.resample(f"{n}D").apply(lambda d: d.corr())

dcorr(df, 20)
14:38
oh yeah, the fern is really pretty :)
I could remove the intermediary frames from the canvas, but doing so would be an unholy terror of cross-scope communication
I've got coroutines and closures and functools.partial out the wazoo
@AndrasDeak Gotcha, thanks for the clarification.
@piRSquared I roughly seem to get the same output
DSM
DSM
@piRSquared: np.isclose gives me all Trues.
14:41
the only non-repro bit there seems to be the random engine, right?
there's a long ongoing discussion about changing the internals of np.random vis-a-vis breaking tests that rely on reproducibility
looking at the discussion it seems to me that for the time being random state is promised to be reproducible in numpy
for the relevant NEP (concerning relaxing that promise) see github.com/rkern/numpy/blob/nep/rng/doc/neps/…
Hmm, I need an object that's kind of like functools.partial, except I can investigate the return value at some point after it's called. Like:
x = Thing("foo".replace, "f", "h")
x.execute()
print(x.last_returned_value) #"hoo"
Does this already exist, or shall I write my own?
@Kevin In preparation for improving my IFS program, yesterday I wrote some Tkinter code that displays images created in another thread. It uses all sorts of fancy clever stuff, including a custom event and an interruptible sleep function. Today, I realised I could get almost the same functionality just using .after. Oh well, the threading stuff may come in handy one day. :)
cabbage..
14:46
I'm quite familiar with that kind of situation :-)
Can anyone tell me a real life usage for lambda functions.. like a scenario where they would be useful
wherever a regular function is useful but you're lazy to type it out and you're only using it once
I understand they are single line functions but what is the point? I can write normal functions in single line
typical use cases involve map
yes, the capabilities of a lambda are a subset of the capabilities of full functions, if that's what you're asking
so.. In real world no one uses lamda?
14:48
@Neoares late to this thread, but I do all of my deep learning using docker. I wouldn't recommend docker-compose. I personally use nvidia-compose, which is similar, but allows for easily mapping GPU's into a container
59 secs ago, by Andras Deak
wherever a regular function is useful but you're lazy to type it out and you're only using it once
huh who says that ?
@Kevin I don't think there's anything like that in the stdlib. The closest is lru_cache, but that doesn't give you access to the last result, although it must internally keep track of that so it can do the LRU stuff.
@Anarach I have no idea where you got that conclusion from
I lambda all the time in my production code... (even though I code c# professionally :( )
14:49
@MooingRawr In Python, or JavaScript?
@MooingRawr Where would one use it? Like I dont know where to use it.
@user3483203 I've never used docker in windows xD
Which windows version are you on?
My tolerance for lack of MCVE is proportional to the amount of time since the last time I wasted 30 minutes debugging someones code without seeing it.
@PM2Ring sorry had to ninja edit it
14:49
def i_hate_itemgetter_and_naming_is_hard(item):
    return item[0]
first = map(i_hate_itemgetter_and_naming_is_hard, list_of_values)

first = map(lambda item:item[0], list_of_values)
@Anarach where you don't want to declare a whole function just to get a function to work on an object and it's most likely not going to be reused (function wise)
also I can imagine a dispatch dict to be populated with lambdas
@PM2Ring Ok. I thought there might be something in the async libs, but if we're being honest I'd probably roll my own solution anyway.
Aren't "single-line" full functions ugly or non-PEP8?
Lambda in Python is often used for the key function to sort / sorted, and groupby.
14:51
The simplest answer I can think of was posted above me as I typed this
@user3483203 10
OK, single-line full functions are OK for PEP8
> Yes:

def f(x): return 2*x

No:

f = lambda x: 2*x
since when?
since when what?
@Neoares Docker integration on 10 is much simpler than on previous versions. I personally do all of my learning on a unix based system, but I test on windows and have no issues. That's one of the nicest things about Docker.
14:53
It's not recommended to use lambda for map or filter: the equivalent list comp / generator is more efficient since it avoids making a function call on each iteration. It's best to stick with C functions for map and filter
@AndrasDeak it's OK for pep8
@Kevin There could be. I've hardly touched async.
map and filter aren't recommended at all :P
@Neoares 01-Aug-2013 the latest
sometimes you need to map :( sometimes you don't... :\
14:54
oh
@MooingRawr Almond Joy's have map
s = '1 2' question: how do I add these two numbers together. sum(map(int,s.split(' ')))
@piRSquared sorry I don't get it after googling what an Almond Joy's is :(
@Aran-Fey Well, Guido doesn't like them. I don't mind map if it's using a C function.
@MooingRawr What you've got is pretty much what I'd do.
Old commercial:
Sometimes you feel like a nut, sometimes you don't. Almond Joy has nuts, Mounds don't.
14:57
@Kevin I believe he was using it as an example for using map
all I'm saying map is useful in places, other times it's overkill
AD'd Kevin'd ? o.o? :thinking: don't know which one to use here I guess both
The cadence of your statement reminded me of the commercial
oh okie.... :D
And I like candy
what's your favourite candy ?
14:58
@piRSquared TIL Almond Joy. And now I know that the early Allman brothers' band name was a pun. en.wikipedia.org/wiki/The_Allman_Joys
Seriously, I'm embarrassed to admit it... candy corn
@AndrasDeak Oops, this is what happens when I read messages context-free
contextly-free? context-freely?
I think it's 50-50 both of your fault ;)
contextly-freely :D
@PM2Ring Laurel, I didn't know that.
15:02
The old "surgeons general" language weirdness
I actually want to know the answer to Get all the pixel locations inside a closed figure in python, too bad nobody's going to touch it with a score like that
Presumably there's some semi-efficient solution, since MS Paint can do it
opencv could likely help with that
too bad OP didn't do anything in the way of finding an answer
You could run a point-in-polygon algorithm on every single pixel, which is a mere O(ridiculous) complexity
@Kevin It's unclear whether he has a closed figure, or just some polygon vertices.
Maybe a hybrid solution: flood fill the outside of the figure, then pick a point not touched by that flood fill, do a P-in-P check, and flood fill it. Repeat until no points are left to check.
OP has a collection of pixels that they claim is part of a closed figure
they aren't telling us where it came from, so this is probably also XY
15:10
"when all joined it would form a closed figure" could indicate that they aren't actually all joined. Yet.
My interpretation is he only has the coordinates of the vertices.
In which case, he probably needs a convex hull algorithm.
and not even in any given order
@PM2Ring unless the shape is not convex
My interpretation is that he has the coordinates in order.
15:13
@AndrasDeak Very true. :)
Gotta love those ambiguous OPs
s/love/close/ :P
Hours of fun arguing about headcanons
But even then, determining the convex hull could be useful.
we just need a concave hull
pointwise checks might be the easiest way still docs.opencv.org/2.4/modules/imgproc/doc/…
fortunately I don't care
15:17
We still need one more vote to close that typo Q that Aran-Fey linked a while back. stackoverflow.com/questions/50967329/…
I'd quite like to see the source code for that function.
@Kevin it's open ;)
@AndrasDeak Done.
Only to those with the gumption to look for the repository
Okay.. So from this I understand that .. Lambda is used along with some other operations like map where defining an actual function is cumbersom
so its a shortcut to defining one time use function..
15:19
@Anarach you definitely should never bind a lambda to a name, so yeah
Funnily enough, inside a map call is where I'm least likely to use a lambda.
@Kevin ?? okay.
I prefer (x+23*42 for x in thing) over map(lambda x: x+23*42, thing). map only wins when its first argument can be a callable that already has a name
15:21
@AndrasDeak 50 quatloos have been deposited to your account
payday came early eh
result = counter % 2 == 0 ? -1 : 1; makes me think it really is doing a point-in-polygon test by counting the number of intersections with the contour's edges
:waves: @tilaprimera
"intel license agreement", that's new to me
15:25
en.wikipedia.org/wiki/Intel_Open_Source_License "The Intel Open Source license is identical to the BSD license with the following section added: EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF YOUR JURISDICTION. [...]"
ah, nice, thanks
Hmm, I changed my mind. I don't think it's counting the number of intersections of the countour's edge vs a line segment extending from the tested point to a point known to be outside the polygon. Rather, it's determining the... I'll call it "chirality"... of the point with respect to each edge.
If we imagine that a line segment divides the plane into "left" and "right" halves, then the chirality of a point w.r.t. that segment indicates what half it is in.
Then, magic occurs, and you know whether the point is in the contour or not.
That makes sense, there are algorithms like that. If you're always on the left of a (directed!) countour, you're inside
15:41
^ Excellent name
@piRSquared my name?
does that algorithm assume you're giving it an ordered series of points?
yes, but a closed contour will always do that
@Seanny123 Sean... it's a good one (-:
15:42
Hmm, but it's got to be more complicated than "number of edges that give the point left chirality, mod 2". If you draw a unit square whose segments divide the plane into nine categories, then five of the categories have an even number of left-chiralities, and four of them have an odd number.
Quite popular!
@Kevin points inside will have the same chirality throughout
That seems true for convex polygons, but I'm not convinced it's true for all polygons
An L-shaped polygon will have the same chirality only at its elbow
the mod-2 might be related to the even-odd rule
are we referring to whether the point is to the left or right of some vector as chirality?
15:45
Yeah
@Kevin hmm, you're probably right
That Jordan Curve page links to a classic weird topology fractal thing: Alexander's horned sphere
so you'd have to compute the angle traversed by the ray from the point to the curve, perhaps
can anyone think of a counterexample to if a point is inside a polygon, it will be to the left of more than half of its edges? Or an example of This point is inside this polygon, but it is to the left of at most half of its edges?
yeah, I can, a triangle
/disregard
@MoxieBall what is the definition of "to the left"
DSM
DSM
15:51
Yeah, if you're in the middle of a hexagon with the pointy bit at north and south, don't you kind of have exactly three to your left? And to your right?
just if you pick an order to traverse the vertices so the edges are directed and extend them infinitely
@DSM left was assuming that everyone would just know I was picking some counter-clockwise traversal of vertices
The strict definition of leftness might be something like "A is to the right of BC if angle ABC is between 0 and 180 exclusive, and it is to the left if it's between 180 and 360 exclusive"
And "A is to the right of BC" is equivalent to "A is to the left of CB"
being left from an edge makes sense because as Moxie said, edges have a direction on a closed contour
i.e. in a hexagon you're on the left (or the right) side of all 6 edges, no matter its orientation
I'll see myself out
I've unconvinced myself that cv is doing anything with chirality, to begin with. Still trying to figure out why line 125 is only checking "is the point completely above, below, or to the right of the line segment's bounding box?" and not "is it to the left?"
16:00
I'm changing my tentative hypothesis to "A point is inside a polygon if it is to the left of a number of edges greater than half the number of edges rounded up"
And the condition just before the return 0 seems like it should only be able to correctly determine if the point is directly on the edge, iff the edge is perfectly horizontal
I have tested this with scribbles for polygons with up to 6 sides.
there's a chance that this comment refers to our function github.com/opencv/opencv/blob/…
I'd find it more logical for it to refer to the next function, but who knows
ah, no, references would be here docs.opencv.org/2.4/modules/imgproc/doc/… but none are linked for our function
I found a pdf of Computational Geometry in C. Chapter 7 does look relevant.
The two code segments in 7.4, "Point in polygon", don't resemble cv's code very much.
@MoxieBall is this a counter example? Still not sure if I understand correctly...
16:13
It mentions that the winding number approach is inefficient because it uses trig, but Wikipedia says a non-trig-involving winding number approach has been around since 2001. This pdf may be behind the cutting edge, then
@piRSquared It sure is, I think I'm just gonna throw out my drawing board using the left/right idea
DSM
DSM
16:36
Congratulatory cupcakes (congratulating someone else, I'm afraid) were delivered to the office kitchen. Quite yummy.
hows your diet going though :D ?
I'm on three different diets. All three are going quite well.
DSM
DSM
Two cupcakes worse than it was a while ago.
I'm impressed by people who can stay on a diet, personally I eat healthy but I can't fathom not being able to eat something because of a diet...
dist on line 135 is the magnitude of the cross product of P-V0 and P-V. I think you can find chirality by checking the sign of the magnitude of the cross product in this way.
16:45
yup
But you can only reach that line if P is inside or directly to the left of the bounding box of the V0-V line segment. So I think that means it's doing a raycasting algorithm, with the ray going from P to (infinity, p.y). That's why you can continue if the point is above, below, or to the right of the segment's bounding box - the ray can't possibly intersect the segment in that case.
So the chirality test is necessary, but not sufficient, to see if the ray intersects the segment. You also need if( v.y < v0.y ) dist = -dist; to negate the result, because reasons.
Yesterday, I took 49 lines of ruby and turned it into 76 lines of python. And then took 74 lines of ruby and turned it into 36 lines of python. I think the python was more readable in both cases, but it's interesting how clarity isn't necessarily correlated with conciseness.
I'm sure a better rubyist could clean the ruby code up and have it be way clearer while keeping its conciseness
00:00 - 17:0017:00 - 23:00

« first day (2805 days earlier)      last day (2368 days later) »