How to compute the difference between position vectors in c++ [closed]

I am an 2nd year engineering student with very little experience with anything to do with coding. I am working on a design project where we are building an X-Y Plotter to generate “random” motion in a rainfall simulator that is being used in a lab.

I have been able to write a program in C++ that will generate an x_coordinate and a y_coordinate as you can see below. I was wondering if anyone had suggestions on how I could store the position it is currently at [x1,y1] and find the distance to the second position [x2, y2] from that last position.

I am hoping my final result will be a program which:
Step 1: Generates a position.
Step 2: Moves to that position.
Step 3: Generates a new position.
Step 4: Calculates the distance to the new position.
Step 5: Repeat steps 2-4

Any advice or direction on what to research would save me lots of time. Thanks!

#include <iostream> #include <stdlib.h>     /* srand, rand */ #include <stdio.h>      /* printf, NULL */ #include <random>  float x_position; float y_position; float x_coordinate; float y_coordinate; int x_MAX; int y_MAX; int i = 0; int positionCount = 100; using namespace std;   int main() {   //Create Limits      cout << "Enter Max Value for X:";         cin >> x_MAX;     cout << "Enter Max Value for Y:";     cin >> y_MAX;      srand(1);     //Generate Coordinates     while (i < positionCount) {          x_coordinate = rand() % x_MAX;         y_coordinate = rand() % y_MAX;          cout << "New Position Coordinate is: [" << x_coordinate << "," << y_coordinate << "]" <<endl;           i++;   }     return 0; } ``` 

Count to infinity problem (routing) between unsynchronized stations(tricky)

i was wondering, will count to infinity can occur in the following cases? if so, will it necessarily occur or can the routing tables stabilize themselves?

enter image description here

Distances:

  1. From A to B – 3
  2. from B to C – 4
  3. from C to A – 2

cases:

1)if line AB fell, can a count to infinity problem occur? will it necessarily occur or the routing tables can stabilize themselves?

2)AB and AC were disconnected on the same time, and we know the stations are not synchronized(the distance vectors are sent from each station in a different time, each according to its inner clock that is not synchronized with other stations clock).

my attempt:

1)if line AB was disconnected, A knows it can no longer reach B, so it removes it from the table. now if it receives an update from C saying it can get to B with a cost of 4, than A knows it can get to C with a cost of 2, so totally 6. now, there might occur a ping pong between A and C while trying to reach B, A updating it can get by 6, then adding 2 each time (from A to C). if like in the second case, the stations are not synchronized, then it will not necessarily happen, because if the distance vector update after the routing tables stabilizied(assuming it can), then the count to infinity situation might not occur. however, i am not sure how to write the routing tables in this case and would appreciate help.

2)complicated, but i think that in this case, it might happen too, but not necessarily, as if AB and AC disconnected at the same time, if they are not synchronized, meaning if we wait enough time, the routing tables should be fixed. the reason it can happen(i am not sure, but again i think it can, but not necessarily happen): since AB and AC disconnected at the same time, B knows line AB is down so it removes it from the tables. now B tries to reach A via C, and C tries to calculate the distance using B to reach A (since they are not synchronized the distance vectors can be sent in different times from different stations using its own inner clock that is not synchronized with other stations)

I am pretty sure i did a mistake and would very much appreciate your assistance in understanding it better.

thank you very much for helping me

Is there a difference between a rainbow table and a dictionary attack?

I’m trying to learn a bit more about the different types of attacks but as far as I understand it, a rainbow table is a large collection of prehashed data which is the compared to hashed data gathered from a target. A dictionary seems very similar but I’m struggling to find anything that can specify the differences between the two, if there are any.

Many thanks!

Why HOG angular bins have values between 0 and 180 degrees?

I have learned that HOG angular bins have values from 0 to 180 since the algorithm uses unsigned gradients. I am failing to understand why.

As far as I know gradient orientation is calculated as

angle = atan(S_y / S_x) 

where S_x and S_y are image gradients in x and y directions respectively.

Provided that S_y and S_x are non-negative, the ratio will also never be negative. Hence, the angle should be in range from 0 to 90 degrees (see atan graph below). What am I missing?

enter image description here

Difference between the SRD and the Basic Rules

This question came up in the context of this question: Is D&D Beyond an official rules source? since there was brief discussion about how the SRD is not considered official and I wondered if the Basic Rules were/weren’t as well (that is not the scope of this question).


Are there any differences between the Basic Rules and the SRD?

Do they have different purposes, content, publishing methods (for example)? Does it have to do with licensing?

If they are the same, why are they referred to as two separate things with separate names?

What are the interactions between Rage and Vaprak’s Rage?

Disclaimer : this is an ultra-specific oddball that will likely never happen to anyone but me. Read only if you have time to kill !

Shapechange is a 9th level spell that allows a player character to assume the form of another creature, while retaining their race/class/other benefits if the new form can physically use them. While the spell is normally restricted to Self-only, it is allegedly possible to make a Spell Glyph of this spell (requiring access to two 9th level spell slots, such as with a Tome of the Stilled Tongue or a Boon of High Magic) to activate onto a different target than the glyph caster — opinions vary on whether bypassing a self-requirement in this way is possible, but for the purpose of this question, let’s assume that it works.

The Frost Giant Everlasting One has an ability called Vaprak’s Rage, which is similar to, but not identical to a Barbarian’s Rage class feature :

As a bonus action, the giant can enter a rage at the start of its turn. The rage lasts for 1 minute or until the giant is incapacitated. While raging, the giant gains the following benefits: – The giant has advantage on Strength checks and Strength saving throws – When it makes a melee weapon attack, the giant gains a +4 bonus to the damage roll. – The giant has resistance to bludgeoning, piercing, and slashing damage.

Suppose that a Wizard makes a Spell Glyph of Shapechange, and then, that a Barbarian triggers the glyph and assumes the form of a Frost Giant Everlasting One.

Now that our premise has been established, several questions emerge :

  1. Can the Shapechanged Barbarian benefit from both Rage and Vaprak’s Rage, gaining both damage increases ? (Not sure whether the “Same Name Effects Stacking” rule applies here)

  2. If, for some reason, the Barbarian has access to spellcasting, can he cast spells & concentrate on them while Vaprak-Raging but not regular-raging ?

  3. Are his Rage-related class features, such as Frenzy (if the Barbarian is a Berserker) and Relentless Rage, “enabled” while Vaprak-Raging but not regular-raging ?

  4. Other interactions I may not have thought about, etc.

Does switching between using a versatile weapon one-handed to two-handed cost anything with regards to the action economy?

The versatile weapon property says (PHB, p. 147):

Versatile. This weapon can be used with one or two hands. A damage value in parentheses appears with the property–the damage when the weapon is used with two hands to make a melee attack.

A weapon with the versatile property, such as a longsword or a quarterstaff, can be wielded with one or two hands. Does it consume any part of the action economy to switch between using one or two hands on your turn?

Intuitively I’d say no, I imagine it costs absolutely nothing, but I can imagine, at worst, there being arguments for it costing your “free object interaction” (PHB, p. 190). Which is it?

(Below are some related Q&As, but not specific to versatile weapons, sadly).


The accepted answer to a related Q&A (thanks @NautArch) suggests that:

Taking your hand off the weapon should not require any action expenditure – you are just letting go of it, same as if you dropped it.

You can then use your free object interaction to restore your grip after casting.

The reasoning for the first case makes sense, but the second case isn’t backed up by anything, although I can see the logic behind it.

The errata posted in that answer, to me, suggests that it would in fact cost nothing to grip the weapon with a second hand, almost like it’s “part of the attack”, similar to how the Ammunition weapon property works, but again, this is logic, not RAW.

To give a concrete example, if we imagine that a PC’s turn starts with a longsword in one hand and a spellcasting focus in the other; they spend their bonus action casting a spell with their focus, and then spend their free object interaction putting that focus away. With only their action left, can they now attack with their longsword using it as a versatile weapon (i.e. dealing 1d10 damage instead of 1d8)?


See also, the “following round” scenario of this question (thanks @Medix2), which involves sheathing a shortsword and attacking with a longbow that requires two hands. This is almost exactly the same scenario as the one I detailed above.

Does OpenVPN encrypt my traffic between my computer and VPN server?

I set up my own VPN by installing OpenVPN on a Ubuntu server, then I download client.ovpn file from Ubuntu server to my Windows laptop. And then, I import that client.ovpn to OpenVPN GUI app on Windows and finally, I connect to my Ubuntu VPN server and everything work fine.

I installed OpenVPN on Ubuntu server using this instruction: https://github.com/angristan/openvpn-install

So I think traffic flow will be like this:

My computer (browser,...) --> Ubuntu OpenVPN server --> Internet. 

Does OpenVPN GUI encrypt traffic between my computer to Ubuntu OpenVPN server?

What are the correlation between Actor model and Reactive Programming

Could anyone explain the difference/correlation between the Actor model and Reactive programming?

It seems that they are located at different levels of abstraction – one can design the interaction between the components of any distributed system using Actor approach, they would send messages, and inside the actors, write code in reactive style?

this question related to How do Functional Reactive Programming and the Actor model relate to each other?

However, the answers wasn’t clear enough, and my question relates reactive programming in general, not FRP in particular.

What is the difference between a Type and an Abstract Type?

In my data structures course we are given definitions for Type and Abstract Type but they confuse me.

A type is a set of values and the operations you can do on them. The set of operations is called an interface.

Wait, what? Do this mean that Type = set of values + interface?

An Abstract Type is a type only accessible through its interface.

I fail to see how this differ from the Type definition. You always need to use the interface in order to do anything with the set of values. Are there types that can be accessed without having a set of operations defined on them a.k.a an interface?