mathematics – Calculate angle of rotation around a local y axis to face projected point

I need to write code (in HLSL) which will take an arbitrary point A in space, a plane normal, and a point P on that plane, and produce an angle representing the rotation (from the plane’s x axis, around the plane normal) the point P would need to make in order to face the projection of A on its plane.

If that seems like a mouthful, I’ve included a diagram:

enter image description here

In the above diagram, A is represented by a black cube, which is projected onto the XY, YZ, and XZ planes.

The use case is that the blades of grass need to be rotated around their local y axis in order to face the projected point. Performing the rotation is trivial but I can’t find a way to get the angle.

assembly – To multiply and then add four double precision point values through MIPS

I am assigned to write a program that should multiply and then add four double precision points values in MIPS I wrote the following code,

    doubleval1: .double  7.2
    doubleval2: .double 6.7
    doubleval3: .double 3.3
    doubleval4: .double 1.2
    l.d $f0,doubleval1 
    l.d $f2,doubleval2 
    mul.d $f12, $f0, $f2
    li $v0, 3
    l.d $f4,doubleval3
    l.d $f6,doubleval4
    mul.d $f12, $f4, $f6
    li $v0, 3

This code multiply all the predefined inputs, I want to ask can I add them all together? as it is the question requirement “then add four double precision points values”, Thank you.

c – Does it break strict aliasing rules if I point to byte arrays with packed struct pointers?

I’ve been familiarizing myself with C’s strict aliasing rules. I’ve looked at several examples of what not to do, and it always involves casting floats as ints, or casting structs to uint32_t pointers, which to me is obviously bad.

However, in my embedded code, I frequently need to work with CAN data buffers. These are 8 byte buffers, and in many cases the protocols and interfaces I’m working with pack fields together in their packets without any padding. So in order to keep the code easy to read and work with, I define the packet as a packed struct, and then typecast the CAN frame’s data buffer (a uint8_t(8)) to a struct pointer, and then modify the buffer by modifying the struct.

For example:

#define DATA_SIZE 8
struct can_frame{
    uint32_t canid;
    uint8_t dlc;
    uint8_t data(DATA_SIZE);

struct packet_example __attribute__((__packed__)) {
    uint8_t field1;
    uint32_t field2;
    uint16_t field3;
    uint8_t field4;
_Static_assert(sizeof(struct packet_example) == DATA_SIZE);

void prepare_packet()
    struct can_frame frame;
    struct packet_example * p = (struct packet_example *) &(;
    frame->field1 = 1;
    frame->field2 = 2;
    frame->field3 = 3;
    frame->field4 = 4;

Is this considered a valid use of C? Or should I stop doing this? Do I need to enable -fno-strict-aliasing? What are the implications of coding this way?

Compiling this kind of code with -Wall and -Werror doesnt give me any warnings and it proceeds fine. However, after reading about strict aliasing, I’m starting to worry that perhaps I’m doing something wrong that the compiler isn’t warning me about.

multivariable calculus – determining pressure gradient for a point

Where velocity is $mathbf{u}=u(z)mathbf{k}$, and a wall described as: $r = 1(zleq0); r = 1 + bsin{z}$ $(zge0)$

Using cylindrical coorinates $(r, theta, z)$, where $0<b<1$ is constant.

  1. find the pressure gradient at a general point $z > 0$ and
  2. find all when $p_{z}$ (pressure gradient) is zero.

Can I find z by manipulating the equation?:

$z = frac{r-1}{bsin}$

given $r = 1 + bsin{z}$; then what is theta?

Where might I begin with integrating this equation?

I’m thinking:

$nablamathbf{u}=frac{1}{r}frac{partial}{partial r}(rfrac{partial u}{partial r}) $

then substituting this into:

$nablamathbf{u} = frac{1}{mu}(frac{partial}{partial z} – rho F_{z})$

to get:

$frac{mu}{r}frac{partial}{partial r}(rfrac{partial u}{partial r}) = frac{partial p}{partial z}-rho F_{z} = const.$

How to find all locations from a source point at Google Map?

Taking a scenario. I searched a location at

Taking the location as a centre, how to find all locations around the location within a radius of certain meter or kilometre?

With Regards

2d – Bounce with 2 contacts point doesn’t work without some trick

Sorry in advance for my bad level in english :/

I have the same issue as the one on this topic :

2D physics engine: Impulse based collision response with contact point manifold

I must separate linear and angular impulse resolution, else I don’t have bounce with 2 contacts point. I don’t understand why because I am using the same way like Matter.js

public void SolveVelocity(Pair _pair)
            if (!_pair.tk_isActive)

            Vector3 rpA_;
            Vector3 rpB_;
            //Normal Impulse
            float linearImpulse_X;
            float linearImpulse_Y;
            float angularImpulse_X;
            float angularImpulse_Y;
            //tangent Impulse
            float tangentLinearImpulse_X = 0;
            float tangentLinearImpulse_Y = 0;
            float tangentAngularImpulse_X = 0;
            float tangentAngularImpulse_Y = 0;
            Vector3 tangent;
            Vector3 _normal = _pair.tk_normal;

            int _count = _pair.tk_count;
            float J_Scalar;
            float JT_Scalar;

            float _miA = _pair.tk_bodyA.massI_;
            float _miB = _pair.tk_bodyB.massI_;
            float _iA = _pair.tk_bodyA.inertiaI_;
            float _iB = _pair.tk_bodyB.inertiaI_;
            float rv;
            float _uS = (float)Math.Sqrt(_pair.tk_bodyA.uS_ * _pair.tk_bodyA.uS_ + _pair.tk_bodyB.uS_ * _pair.tk_bodyB.uS_);
            float _uC = (_pair.tk_bodyA.uC_ * _pair.tk_bodyA.uC_ + _pair.tk_bodyB.uC_ * _pair.tk_bodyB.uC_)/2.0f;
            float _elasticity = (_pair.tk_bodyA.tk_elasticity + _pair.tk_bodyB.tk_elasticity) / 2.0f;

            Vector3 _positionA = _pair.tk_bodyA.position_;
            Vector3 _positionB = _pair.tk_bodyB.position_;

            Vector3 _velocityA = _pair.tk_bodyA.velocity_;
            float _omegaA = _pair.tk_bodyA.omega_;

            Vector3 _velocityB = _pair.tk_bodyB.velocity_;
            float _omegaB = _pair.tk_bodyB.omega_;       

            for (int c = 0; c < _count; c++)
                rpA_ = _pair.tk_contacts(c).tk_position - _positionA;
                rpB_ = _pair.tk_contacts(c).tk_position - _positionB;
                Vector3 _relativeVelocity = (_velocityB + new Vector3(rpB_.Y * -_omegaB, rpB_.X * _omegaB, 0)) -
                                            (_velocityA + new Vector3(rpA_.Y * -_omegaA, rpA_.X * _omegaA, 0));

                float _countInv = 1.0f / (_count);
                float _relativeNormalVelocity = _relativeVelocity.X * _normal.X + _relativeVelocity.Y * _normal.Y;
                rv = _relativeNormalVelocity;

                #region Normal

                J_Scalar = (1 + _elasticity) * _relativeNormalVelocity;// * _count*_count
                float crossNA = (rpA_.X * _normal.Y) - (rpA_.Y * _normal.X);
                float crossNB = (rpB_.X * _normal.Y) - (rpB_.Y * _normal.X);
                float _crossASqr = crossNA * crossNA * _iA;
                float _crossBSqr = crossNB * crossNB * _iB;

                float invSum = _miA + _miB + _crossASqr + _crossBSqr;
                float invShareSum = _countInv / invSum;
                float J = J_Scalar * invShareSum;

                if(rv > 0)
                    _pair.tk_contacts(c).tk_normalImpulse = 0;
                    var contactNormalImpulse = _pair.tk_contacts(c).tk_normalImpulse;
                    _pair.tk_contacts(c).tk_normalImpulse = _pair.tk_contacts(c).tk_normalImpulse + J;
                    if (_pair.tk_contacts(c).tk_normalImpulse < 0)
                        _pair.tk_contacts(c).tk_normalImpulse = 0;
                    J = _pair.tk_contacts(c).tk_normalImpulse - contactNormalImpulse;

               /* if(contactNormalImpulse !=0)
                    int i = 0;
                    J += i;

                linearImpulse_X = (J) * _normal.X;
                linearImpulse_Y = (J) * _normal.Y;
                angularImpulse_X = (J) * _normal.X;
                angularImpulse_Y = (J) * _normal.Y; 


                #region Impulse
                //if (rv > 0)
                    Vector2 totalImpulseLinear = new Vector2(linearImpulse_X, linearImpulse_Y) + 0 * new Vector2(tangentLinearImpulse_X, tangentLinearImpulse_Y);
                    Vector2 totalImpulseAngular = new Vector2(angularImpulse_X, angularImpulse_Y) + 0 * new Vector2(tangentAngularImpulse_X, tangentAngularImpulse_Y);

                    if (!(_pair.tk_bodyA.is_Sleeping || _pair.tk_bodyA.Is_Static))

                        _pair.tk_bodyA.oldPosition_.X -= totalImpulseLinear.X * _miA;
                        _pair.tk_bodyA.oldPosition_.Y -= totalImpulseLinear.Y * _miA;
                        _pair.tk_bodyA.oldTheta_ -= (rpA_.X * totalImpulseAngular.Y - rpA_.Y * totalImpulseAngular.X) * _iA;
                    if (!(_pair.tk_bodyB.is_Sleeping || _pair.tk_bodyB.Is_Static))
                        _pair.tk_bodyB.oldPosition_.X += totalImpulseLinear.X * _miB;
                        _pair.tk_bodyB.oldPosition_.Y += totalImpulseLinear.Y * _miB;
                        _pair.tk_bodyB.oldTheta_ += (rpB_.X * totalImpulseAngular.Y - rpB_.Y * totalImpulseAngular.X) * _iB;



Thx in advance for your advise

Tangent space of algebraic variety at a point.

Could you please help me with this problem?

(Springer, Linear algebraic group, 4.1.9)Assume that $X$ is a closed subvariety of $mathbb{A}^n$, $k$ is an algebraically closed field,
Describe the tangent space $T_{x} X$ in the following cases:

(a) $X$ is a point;

(b) $X$ is the affine space $k^{n}, x$ is an arbitrary point in $X$;

(c) $X=left{(a, b) in k^{2} mid a b=0right},$ and $x=(0,0)$;

(d) Assume that $operatorname{char}(k) neq 2,3, X=left{(a, b) in k^{2} mid a^{2}=b^{3}right},$ and $x=(0,0)$.

We have $T_x X cong (M_x / M_x^2)^*$, where $M_xsubset k(X)$ is the maximal ideal of functions vanishing in $x$. So we need to compute $M_x$?

Thank you in advance.

algebraic topology – Proof Verification: Only contractible discrete space is the one point space

I am trying to prove that only contractible discrete space is the one point space. The proof of it can be seen here( and here(

I believe I have a proof, but I do not use connectedness of the unit interval, so I’m asking for verification of my proof.

My proof

Suppose discrete space X was contractible. Any contractible space is path-connected. Indeed, take a homotopy $H colon X times (0,1) to X$ from identity on $X$ to $cost$ on $x_1$. Then for any $x_2 in X$, $H(x_2, -) colon (0,1) to X$ gives a path from $x_1$ to $x_2$ as $H$ being continuous implies $H$ is continuous in each variable.

Now I claim that any discrete space with more than 2 points is not connected. To show this, note that if there is continuous and non-constant map $X to {0,1}$, then $X$ is not connected. As $X$ has more than 2 points, we can find a non-constant set map $X to {0,1}$. And as $X$ is discrete, this non-constant set map must be continuous.

So if $X$ has more than 1 point and contractible, we get that $X$ is path connected but not connected. This is impossible, so $X$ must have one point if it were to be contractilbe.


python – syntax error? Im literally copying it at this point

#I am having a syntax error in the colon after the ‘if another roll line’
#If I copy-paste the code it works but when I type it out it won’t.

import random

print(“Welcome to dice roller”)

min_value = 1
max_value = 20

roll = True

while roll:
print(random.randint(min_value, max_value))

another_roll = (input("Would you like to roll again? ")

if another_roll == 'yes' or another_roll == 'y':
    roll = True

    roll = false

Buying Bitcoin At this point will be profitable or not?

Will it be profitable or lead us to debt?
1 BTC = 30000$-45000$