c++ – Simulation of a falling ball

I am new to C++ programming. Made a simple simulation of a falling ball. Is it possible to somehow improve or optimize this code? What tips can you give for development?

#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int timeFallingBall() {
    static int time(0);
    return ++time;
void fallingBall() {
    cout << "From what height do we drop the ball? (In meters): ";
    double h;                                           
    cin >> h;
    double v = 0, high = 0, s = 0, maxv = 0, g = 9.8;   
    int t = 0;
    double hi = h;
    while (h) {
        t = timeFallingBall();
        v = static_cast<double>(t) * g;
        high = (v * static_cast<double>(t)) / 2;
        h = hi - high;
        if (h <= 0) {
            switch (t) {
            case 1:
                cout << "After " << t << " second the ball has reached the ground! Maximum speed: " << maxv << " m/s";
                cout << "After " << t << " seconds the ball has reached the ground! Maximum speed: " << maxv << " m/s";
        switch (t) {
        case 1:
            cout << "After " << t << " second, the ball is at a distance of " << h << " m from the ground at a speed: " << v << " m/s" << endl;
            cout << "After " << t << " seconds, the ball is at a distance of " << h << " m from the ground at a speed: " << v << " m/s" << endl;
        if (v > maxv) {
            maxv = v;
int main() {
    system("chcp 1251>nul");
    return 0;

unity – Character controller falling with positive speed

I’m having very weird problems with my player’s vertical movement. I’m using a Character Controller component with a capsule collider and no rigidbody. For testing purposes, I’ve ended reducing my jump script to just this line:

    owner.CharacterController.Move(new Vector3(0, 0.01f, 0));

When executing this script, the player should just fly upwards at a constant speed, right? Well, what ends up happening is that the player starts jumping in place repeatedly. The jumps are smooth, as if the movement was being affected by gravity. I thought that the standard Character Controller doesn’t handle gravity automatically and you have to do it yourself, so I can’t understand what’s going on here. There is no other code affecting the player, if I comment that line it just rests in place. If I try a different direction (like (0.01f, 0, 0)) the player moves in a straight line in the provided direction as expected. But when moving vertically, weird stuff happens :S

❕NEWS – Ethereum (ETH) Amount In Exchanges Is Falling Hard! | NewProxyLists

According to data shared by Whale Alert, a total of 367,382 ETH has been withdrawn from leading exchanges such as Bitfinex, Binance, and other smaller exchanges in the past 20 hours. According to a U.Today report, a recent analysis report shows that the ETH balance on cryptocurrency exchanges has dropped to a 15-month low.
What do you think could be the reason for this development?


dnd 5e – Using the optional rule on falling onto a creature, is the fall damage divided between creatures before or after damage resistance/reduction?

Lets use an example through this study: the Martial Warrior (Marty) has been knocked off of a cliff, and falls 100 feet the the bottom, into the square of a Cleric (Clarence). We will assume the DM rolls average damage. Let’s break down this fall in order from general to specific:

General Rule: PHB Fall Damage

A fall from a great height is one of the most common hazards facing an adventurer.
At the end of a fall, a creature takes 1d6 bludgeoning damage for every 10 feet it fell, to a maximum of 20d6. The creature lands prone, unless it avoids taking damage from the fall.

This is the original rule for falling, and the most general rule to follow. In this case, Marty takes the full damage of 10d6, 35 bludgeoning damage.

General Rule: TCoE Falling on another Creature

The second creature here gets to make a saving throw to avoid halving the damage. Clarence fails there save, and splits the damage with Marty: they both take 17 bludgeoning damage.

Specific rule: Monk’s Slow fall

Beginning at 4th level, you can use your reaction when you fall to reduce any falling damage you take by an amount equal to five times your monk level.

The damage is reduced “when you fall,” not when you take damage. This means the damage dealt by the fall is decreased, instead of reducing the damage once it is taken, through resistance, mitigation, division, diversion, etc.
In this specific case, Marty is now a 4th level Monk. If he falls onto Clarence’s space and Clarence fails their saving throw, then the damage of the fall is split between them. However the specific wording of Falling on a Creature states:

…and any damage resulting from the fall is divided evenly between them.

So the damage is first reduced by the Marty’s slow fall, and second split between the two. 35 damage is reduced by 5 times Marty’s Monk level to 15 damage, which is split between them: both characters take 7 bludgeoning damage.

Specific rule: Damage Resistance

If a creature or an object has resistance to a damage type, damage of that type is halved against it.

Clarence is not just a cleric, but a 17th level Forge Cleric in heavy armor, meaning their Saint of Forge and Fire feature takes effect, giving them resistance to non-magical bludgeoning damage. This means the damage taken by Clarence is halved, and only the damage taken by Clarence. So after Marty falls 100 feet, Clarence fails to get out of the way, and Marty’s Slow Fall Feature take effect, finally the damage that is taken is halved last. This means Marty would take 7 Bludgeoning damage from the fall, and Clarence would take 3 bludgeoning damage. If Marty had the resistance instead, this would still not be translated into reduced damage for the other person, as the resistances damage reduction is applied after the damage has been dealt.

Other Specific rules: Various Subclass abilities

All of the subclass features you have listed are great examples of damage reduction, and they all have a similar piece of wording that is different from the Monk’s Slow Fall.

Spirit Shield:

If you are raging and another creature you can see within 30 feet of you takes damage, you can use your reaction to reduce that damage by 2d6.

Bastion of Law:

When the warded creature takes damage, it can expend a number of those dice, roll them, and reduce the damage taken by the total rolled on those dice.

Guardian Coil:

When you or a creature you can see takes damage while within 10 feet of the tentacle, you can use your reaction to choose one of those creatures and reduce the damage to that creature by 1d8.

Song of Defense:

When you take damage, you can use your reaction to expend one spell slot and reduce that damage to you…

Unlike the Slow Fall ability, which takes effect when you fall, all of these features take effect when you take damage. These would all reduce the damage after impact, when both the falling creature and fallen upon creature have already taken the damage.
Thankfully for Clarence, his Raging Ancestral Guardian Barbarian Friend (Barb) is nearby, and she uses her Spirit Shield ability to reduce the damage of the fall by 2d6. Unfortunately for Clarence, Barb rolls garbage, and only reduces the damage by 2. According to the order of operations in the PHB, the damage would be reduced first (from 7 to 5), then halved by resistance, resulting in a final devastating total of 7 bludgeoning damage for Marty, and a brutal 2 bludgeoning damage for Clarence.

dnd 5e – Can you cast a spell with a casting time of 1 action while falling?

The following excerpts are taking from the PHB, Chapter 10, pages 202-205.

Regarding casting time:

Most spells require a single action to cast . . .

Here we see there are no restrictions on what is happening during a turn, other than the caster needing to spend the appropriate action.

Regarding range:

The target of a spell must be within the spell’s range . . . once a spell is cast, its effects aren’t limited by its range, unless the spell’s description says otherwise.

Again, nothing prohibiting positioning, only that the target be in range at the moment the spell is cast.

Regarding components:

Verbal: Most spells require the changing of mystic words . . . a character who is gagged or in an area of silence . . . can’t cast a spell with a verbal component.

Somatic: Spellcasting gestures might include a forceful gesticulation or an intricate set of gestures . . .

Material: . . . A spellcaster must have a hand free to access a spell’s material components – or to hold a spellcasting focus – but it can be the same hand that he or she uses to perform somatic components.

Here, there is nothing RAW stating these cannot be done while falling. However, you as a DM are within your power and reason to determine if components are possible, or only possible with checks, to satisfy the spell’s requirements.

For example, somatic components simulate gestures that may be difficult to perform while plummeting toward the ground. It may warrant a Dexterity or Athletics check to pull off against the wind and other forces affecting the caster. Likewise, it might be hard to keep hold of a large staff while spinning wildly in the air. Concentration can be used as a catch-all for the difficulty of the situation.

I haven’t personally employed these (I tend to complicate my encounters enough IMO), but I have played at a table where our DM used such techniques sparingly. A particular instance was a vicious storm in which our PCs were described as struggling to even walk upright; the DM had the wizard make a Strength (Athletics) check to be able to hold his arm out with his staff to cast. I agreed with the rationale, and I felt it added a sense of weight and severity to the situation, as well as cause for celebration when the player succeeded. This was the general result we got from whenever the DM employed this technique, in that we felt it added realism and value overall to the story.

Again, none of these are required explicitly in RAW, but are reasonable considerations based on the scenario and what you want your players to accomplish.

digital circuits – Propagation and contamination delays with different delays for rising and falling edges

In the Digital Design and Computer Architecture by David Harris, Sarah Harris the authors explain what are propagation delay and contamination delay in the following way:

The propagation delay $t_{pd}$ is the maximum time from when an
input changes until the output or outputs reach their final value. The
contamination delay $t_{cd}$ is the minimum time from when an input changes until any output starts to change its value.. . $t_{pd}$ and
$t_{cd}$ may be different for many reasons, including different
rising and falling delays

So I draw from the bold text (emphasized by me) for any circuit there is a only pair of these measures values. That is to say, if a circuit has a different delays for its rising edge (transition from 0 to 1) and falling edge (transition from 1 to 0), $t_{pd}$ is about the longest between them, and $t_{cd}$ – about the shortest.

The authors show such circuit to define the critical and short paths:

enter image description here

and then expand on the aforementioned measures by stating that taking notice of both the critical and short paths, it is true for this circuit:

$$t_{pd} = 2*t_{pdAND} + t_{pdOR}$$
$$t_{cd} = t_{cdAND}$$

Let’s suppose we encounter the very case: the AND gate has a different delays for its rising and falling edges. Does it mean these equations might be wrong? There is the falling edge shown in the picture. So if this edge is quicker in terms of delays, it’s either nonsense to use $t_{pdAND}$ here (because it indicates the slower rising edge measure but we are talking about the falling one) or $t_{pd}$ is not relevant to the matter in hand (falling edge).

As I’m concerned, for these types of situation it would be reasonable to exploit two different pairs of values: one for a rising edge and another for falling one but this is out of line with the bolded author statement. What’s the right way to address these possible circuit delays differences?

Finite sum with falling factorial

I need to evaluate the following finite sum:

sum_{j=0}^{h}(-1)^jbinom{h}{j}(jx)_{k},qquad kgeq h,, xinmathbb{R}^{+}



is the falling factorial. Any hints would be appreciated!

dnd 5e – What is the falling damage of tiny creatures?

D&D is not a physics simulator.

So citation to real world physics doesn’t really help here. The rules for falling state:

A fall from a great height is one of the most common hazards facing an adventurer. At the end of a fall, a creature takes 1d6 bludgeoning damage for every 10 feet it fell, to a maximum of 20d6. The creature lands prone, unless it avoids taking damage from the fall.

No provisions are made for creature size, so unless the creature has an ability specifically reducing falling damage, the normal rules apply.

dnd 5e – Sleet Storm: do crampons stop you from falling prone?

Taking into account the rest of the spells effects, this could be understood in two ways (emphasis on clarity changes):

The ground in the area is covered with slick ice, making it difficult terrain. When a creature enters the slick ice’s area for the first time on a turn or starts its turn on the ice, it must make a Dexterity saving throw. On a failed save, it falls prone.

This would mean that yes, the crampons are enough to counteract the prone effect of the spell. Alternatively:

The ground in the area is covered with slick ice, making it difficult terrain. Due to the various effects of the spell (including the slick ice, battering hail, etc.), when a creature enters the spell’s area for the first time on a turn or starts its turn there, it must make a Dexterity saving throw. On a failed save, it falls prone.

This would mean protection from the slick ice alone would not be enough, and the creature would still have to save to not fall prone.

Personally, as a DM I would rule that the crampons are not enough. Having a major portion of a level 3 spell partially thwarted by a 2gp purchase that likely any humanoid can access seems to nullify the use of the spell. The only reason a person would have crampons already strapped to their feet is if they were expecting slippery terrain, and the value of the spell is taken away if all it does is add more slippery terrain.

unity – How can a object be prevented from falling?

I tried to make projectile for a Spaceship for 3D game. But whenever I instanitate an projectile and make it move, ıt falls . I assume because of rigidbody but couldn’t find how to fix. I want projectile to move forward and not fall.

Those are components of projectile

enter image description here

Those are codes I used to keep projectile from falling.

void Update()
    //transform.position += new Vector3(-1, 0, 0) * 0.1f;
    //GetComponent<Rigidbody>().velocity = -transform.right * 100 * Time.deltaTime;
    //GetComponent<Rigidbody>().AddForce(transform.up * 0.000001f);