c++ – What’s the maths behind checking line of sight

I understand in unity there is Phsyics.LineCast(Vector A, VectorB). What’s the maths behind doing that, the only thing i can think of is going along the line at small intervals and seeing whether it collides with an object or setting the line as a cuboid with a small width and height but depth equal to vector1-vector2 but then that would be non-axis aligned cuboid collision which seems pretty expensive.

Could anyone help me on this?

Given 2 amoeba shaped curves on a plane , is it possible to construct a line such that it diveds the area of each curve in half?

I came across this problem in the art and craft of problem solving, and have been unable to figure out how to solve it..

automation – How to delete the fist line in the file using lua script?

I just started learning script lua. I have a .txt file with the format “user | pass”. how to get “user” and “pass” on the first line and delete them from that file.
This is my command but I can only read the contents of one line, but I can’t separate “user” and “pass”

io.input("/var/mobile/Library/AutoTouch/Scripts/account.txt")
t = {}
for i = 1, math.huge do
    local s = io.read()
if s == nil then
break
end
    t(#t + 1) = s
end

i = 1, #t do
    alert(t(i));
end

Can’t boot to Windows, stuck on Grub BASH-like command line

I have installed Grub in Windows through bootcamp on a MacBook, to dual boot ChromeOS and windows .
However after repairing the hard disk in MacOS disk utility grub shows the command prompt interface and refuses get into the GRUB boot menu

It shows

minimal BASH-like editing is supported.for the first word, TAB lists
possible commands completions.anywhere else TAB lists the possible device or file completion.

When I type exit I get

grub> error exit command not found

Pressing Esc only starts a new line, while choosing Windows from MacOS Startup manager will freeze the screen.

This might be useful

grub> ls
(hd0) (hd1) (hd1,gpt3) (hd1,gpt2) (hd1,gpt1) 

How can I boot in to my Windows partition from this stage?

dnd 5e – Do you need line of sight to cast spells on someone?

It Depends on the spell. And on your DM.

This is true for trying to cast a spell through any type of cover – whether it’s a brick wall, an illusory wall, a curtain of tissue paper, a glass wall, a swinging door. I’ll give you a couple of examples.

I am using roll20 compendium and DnD 5e Wikia for spell descriptions.

Magic Missle:

You create three glowing darts of magical force. Each dart hits a creature of your choice that you can see within range. A dart deals 1d4 + 1 force damage to its target. The darts all strike simultaneously, and you can direct them to hit one creature or several.

First of all, you must be able to see the target. This means that of the above options, you can target something only through the glass wall. The missles might do enough damage to break the wall, but as they are all traveling simultaneously, they will not penetrate. This depends on your DM.

Witch Bolt:

Make a ranged spell attack against that creature. On a hit, the target takes 1d12 lightning damage, and on your turn, you can use your action to deal 1d12 lightning damage to the target. The spell ends if you use your action to do anything else. The spell also ends if the target is ever outside the spell’s range or if it has total cover from you.

“Cover”, specifically, is physical. A glass wall therefore, is total cover, so you can cast the spell, but it would instantly end, which would mean you just wasted a spell slot. Same goes for the brick wall. You can cast it through an illusory wall, though if you don’t know that it is illusory, you probably shouldn’t risk it. Because the spell launches a bolt of force, and not anything physical, it will not swing the door open, and while closed, it is total cover. As for the thin curtain, this is up to your DM. If I were DM, I would say that the curtain is not total cover, but would make you roll at disadvantage to aim well at the target that you cannot see.

Detect Thoughts:

The description says you need to see the creature, so only the glass wall would work. Because you are not sending anything at the creature, and are only “looking through its mind”, the glass wall would not hinder you. Unless you have a mean DM.

Suggestion:

You must be able to see the creature, and the creature must be able to hear you. The swinging door might work if it has a glass window, but otherwise, none of the options would work.

Sleep:

You can most definitely choose the point to be behind any wall, but your ability to aim well will be hindered. If you choose the point on your side of the wall, your DM might rule that creatures that cannot see the point do not fall asleep, even if they are within 20 feet.

For any spell: Some DMs might rule that there cannot be any cover at all. Some might rule that you must always see the target. Modifying the vaguer rules in 5e is one of the purposes of DMs.

As for the last question: If the spell says that the target must be seen, than a blindfolded wizard cannot cast it. Otherwise, it is up to your DM, but you can expect to aim much worse.

c# – line seperate algorithm from 30 characters to 40 characters

Hi all I want to convert 30 char rows to 40 char rows.
each character is different. I just wrote 111-222 to make it clear.

111111111111111111111111111111
222222222222222222222222222222
333333333333333333333333333333
444444444444444444444444444444
555555555555555555555555555555
666666666666666666666666666666
777777777777777777777777777777



1111111111111111111111111111112222222222
2222222222222222222233333333333333333333
3333333333444444444444444444444444444444
5555555555555555555555555555556666666666
6666666666666666666677777777777777777777
7777777777

is there anyway to make it fast . It doesnt work like that.

using (var sw = new StreamWriter(@"C:Usersxxx.txt"))
            {
                bool x = true;
                var sayac = 0;
                var lines = File.ReadAllLines(@"C:Usersaa.txt", Encoding.UTF8);
                for (var i = 0; i < lines.Length; i++)
                {

                    Console.WriteLine(i);
                    var line = lines(i);
                   
                    sw.Write(line);

                    if (line.Length>=40)
                    {
                        sw.Write(Environment.NewLine);
                    }
                   


                }
            }

c# – labels have huge line spacing causing overlapping each other in wpf

Issue:

I have a wpf application with some labels in a Grid. The Grid Row height is not set

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*"></ColumnDefinition>
        <ColumnDefinition Width="1*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <Label Content="Created tickets last week:" Grid.Row="0" Grid.Column="0"></Label>
    <Label x:Name="TicketsCreatedLastWeek" Content="0" Grid.Row="0" Grid.Column="1"></Label>
    <Label Content="Target tickets per day:" Grid.Row="1" Grid.Column="0"></Label>
    <Label x:Name="TargetTicketsPerDay" Content="0" Grid.Row="1" Grid.Column="1"></Label>
    <Label Content="Tickets done Today:" Grid.Row="2" Grid.Column="0"></Label>
    <Label x:Name="TicketsDoneToday" Content="0" Grid.Row="2" Grid.Column="1"></Label>
    <Label Content="Day Ticket Progress:" Grid.Row="3" Grid.Column="0"></Label>
    <ProgressBar x:Name="TicketDayProgressbar" Grid.Row="3" Grid.Column="1"></ProgressBar>
</Grid>

within the WPF Application, it looks like this:
enter image description here

The overlapping itself is not the issue. By making the form bigger, everything shows up correctly.

My main concern is the huge margin around the text. There is no margin set. It appears to be 1 full line height.
enter image description here

Question:

Is there a way to reduce line spacing to 0, so that I can actually format and put margin as I please?

computational geometry – What is the best approach to find the nearest line segment (x1,y1),(x2,y2) from an point (x,y)?

The distance from a point to a line is given by the projection of a line from the point to some point on the line onto a unit vector orthogonal to the line.

First we need same data.

lines = Partition(RandomReal({-1, 1}, {6, 2}), 2)
point = RandomReal({-1, 1}, 2)
Graphics({Line(lines), PointSize(0.02), Red, Point(point)}, 
 Axes -> True)

enter image description here

Then we need unit vectors orthogonal to our lines:

ortho = Normalize /@ (Subtract @@@ dat).{{0, 1}, {-1, 0}};

The distance from the point to the lines is now given by the absolute value of the projection of the line from point to the start of the lines onto the orthogonal unit vector:

dist = MapThread((Abs((point - #1).#2)) &, {lines((All, 1)), ortho})
(*{0.0292868, 0.260295, 0.347937}*)

It is obvious, for our example, that the first line is closest to the point.

pension plan on line

Ok here goes and apologies for any errors or misunderstandings, am 64 years old ex wife stole my pension, got locked down with the coronavirus then got made redundant a week before xmas. I have little or no marketing experience previously a call handler for insurance company.
limited social circle and don't do facebook.
Am looking to build a website using word press part news part forum. similar websites that i have looked at seem to hold out a begging bowl with a donations via paypall…

pension plan on line

16 line python string obfuscator – reduce/compress output size/and increase speed

Here you have it: Possibly the smallest feasible python obfuscator without any real “cheats” when it comes to making something one line, no semicolons etc. all with variable concatenation. some is redundant as hell, but it works, and its surprisingly fast for how inefficient it is.

import sys,zlib,ast,collections #CODED BY FREAK - http://pastebin.com/u/KekSec - LEAVE CREDS IF U USE DONT BE A RIPPER - Original src (updated from time to time): https://pastebin.com/raw/WzYJJnmW
def escape(s):
    ch = (ord(c) for c in s)
    return ''.join(('\x%02x' % c) if c <= 255 else ('\u%04x' % c) for c in ch)
global newcode
code = newcode = open(sys.argv(1)).read()
root = ast.parse(code)
class ShowStrings(ast.NodeVisitor):
  def visit_Str(self, node):
    if len(node.s) >= 5 and "re." not in code.split("n")(node.lineno-1) and ":(" not in code.split("n")(node.lineno-1) and ": (" not in code.split("n")(node.lineno-1): #min length five and no regex statements or dicts allowed
            global newcode
            string=code.split("n")(node.lineno-1)(node.col_offset:node.col_offset+len(node.s)+2)(0)+"".join(code.split("n")(node.lineno-1)(node.col_offset+1:node.col_offset+len(node.s)+len(code.split("n")(node.lineno-1)(node.col_offset-1:node.col_offset+len(node.s)+2).split(code.split("n")(node.lineno-1)(node.col_offset+1:node.col_offset+len(node.s)+2)(0))(0))+4)(:code.split("n")(node.lineno-1)(node.col_offset+1:node.col_offset+len(node.s)+len(code.split("n")(node.lineno-1)(node.col_offset-1:node.col_offset+len(node.s)+2).split(code.split("n")(node.lineno-1)(node.col_offset+1:node.col_offset+len(node.s)+2)(0))(0))+4).find(code.split("n")(node.lineno-1)(node.col_offset:node.col_offset+len(node.s)+2)(0))))+code.split("n")(node.lineno-1)(node.col_offset:node.col_offset+len(node.s)+2)(0)
            compressed="zlib.decompress("+code.split("n")(node.lineno-1)(node.col_offset:node.col_offset+len(node.s)+2)(0)+escape(zlib.compress(node.s))+code.split("n")(node.lineno-1)(node.col_offset:node.col_offset+len(node.s)+2)(0)+")"
            newcode=newcode.replace(string, compressed)
ShowStrings().visit(root)
with open("secret.py", 'w') as f: f.write(newcode)

Any way this can be possibly made faster, as in per cpu cycle action whilst maintaining under 40-50 lines and being in python? and possibly reduce output size?

Also yes I know the “compression” is increasing output file size. its not on purpose, its more of a an encoding at this point, but I’d like to make something that actually ends up compressing the output file somehow.