rotation – Find the vector orthogonal to a quaternion?

Apologies if the title doesn’t quite make sense, it’s been a long time since I did any 3D stuff. I would like to be able to pan my camera up and down with the arrow keys. The camera’s rotation is described by a quaternion, and I need to rotate that quaternion around an imaginary axis orthogonal to the way the camera is pointing (if you can imagine the camera mounted on the front of a big + then the axis I need would be the horizontal bars).

I know how many radians I need to rotate by, but I’m struggling to work out how to get the axis I need to rotate around. I’ve tried to draw what I mean:

MS paint quaternion rendering

The red line is where my camera is actually facing. It (eventually) will be able to tilt left and right as well. The green line is “up” from where the camera is pointing, and the blue line is the axis I want to rotate around for up/down panning. Please try and imagine they’re all at right angles.

How do I rotate my quaternion q around the blue line by r number of radians? Is there something I can do with a matrix here and skip looking for an axis? If it helps I’m using g3n in golang so this is what I have to work with.

reference request – Foliations induced by Vector Fields without Singularities

A well-known type of foliations is the one that is induced by vector fields without singularities. However, I have already read this type of foliations from Geometric Theory of Foliations, Page 28. Unfortunately, I couldn’t understand it very well. Therefore, I am actually looking for highly recommended references for the foliations induced by vector fields without singularities. Thanks in advance.

plotting – Plot a vector field from data

I try to plot a vectorplot3d from a text file, .txt with 3 componements
I appeared like a table or a list at first
and i try to plot the result as vectors,because i have a velocity field
but Vectorplot3d doesnt work
I an a beginner at nmathematica.Thanks

image processing – How to digitize a vector field?

Is there some way that I can digitize both the direction and the magnitude of a vector field accessible in JPEG format?

To clarify what I mean, I want to have the numerical value of: 1]magnitude and 2] direction of all the vectors in a meteorological map like this:

enter image description here

linear algebra – Determine the tuples which the vector $x=lambda_1a_1+lambda_2a_2+ lambda_3a_3+ lambda_4a_4$

We have the matrix $A=(a_1|a_2|a_3|a_4)=begin{pmatrix}
4 & -6 & -3 & -11\
4 & 1 & 4 & 10\
-1 & 5 & 13 & -6\
-4 & 6 & 10 & -24
end{pmatrix}$
and the Q matrix from the QR-
factorization have I found to: $$Q=(q_1|q_2|q_3|q_4)=begin{pmatrix}
frac{4}{7}& -frac{2}{7} &frac{5}{7}& -frac{2}{7} \
frac{4}{7} & frac{5}{7} & -frac{2}{7} & -frac{2}{7} \
-frac{1}{7} &frac{4}{7} & frac{4}{7} & frac{4}{7}\
-frac{4}{7}& frac{2}{7}& frac{2}{7} & -frac{5}{7}
end{pmatrix} $$

I have to determine the (infinitely many) tuples ($lambda_1$,$lambda_2$, $lambda_3$ $lambda_4$$) in R^4$

for which the vector
$$x=lambda_1a_1+lambda_2a_2+ lambda_3a_3+ lambda_4a_4$$

lies on the line $L = span {q_4 }$ stretched by the vector $q_4$

I’m not totally sure how to do that. I think maybe I can use the coordinate vector $(x)_Q$
expressed by $lambda_1$,$lambda_2$, $lambda_3$ $lambda_4$. But how can I use this to find the tuples? Hope anyone can help me?

java – Elevar a la 2da potencia los elementos de un vector

Hola a todos quisiera saber como puedo elevar a la 2da potencia cada elemento de un vector usando el método de la clase Math.pow , porque al parecer como lo estoy haciendo , eleva la potencia como si fuera un solo numero, y no eleva a la potencia a cada elemento del vector , además de esto necesito almacenar en otra variable el total de la suma de las potencias de cada uno de los elementos del vector.
Les dejo mi código aquí:

public class Vector extends Thread{
public static void main(String () args) {

int vector() = new int (5);

int aleatorio = (int) (Math.random()*10 )+1;
int suma=0;
int cuadrado;
int  suma2=0;
for (int x = 0; x < vector.length; x++) {
    vector(x) = (int) (Math.random() * 10) + 1;
}
for(int i =0; i<vector.length; i++) {
    System.out.println(vector(i));
}
//Esta es la suma del contenido del vector
for(int i=0;  i<vector.length; i++) {
suma= suma + vector(i);
}

// Esta es la suma de los cuadrados de cada elemento
for(int i=0; i<vector.length; i++){
    cuadrado= (int) Math.pow(vector.length,2);
    suma2= suma2+cuadrado;
}

System.out.println(suma);
System.out.println(suma2);

}
}

plotting – Efficiently saving a vector graphic with RegionPlot and labels

I would like to save an image as a vector graphic (.pdf), so that when I zoom in, the lines and labels remain crisp. However, the image I am saving also contains components that are generated by RegionPlot. When I save these as vector graphics, the file sizes are massive, hundreds of times larger than the vector graphics not including components generated by RegionPlot.

Is there a way to save a plot so that the labels and lines on the plot are vector graphics, but shaded regions are not? An example of the image I am trying to save is below.

enter image description here

c++ – Gather all IP addresses of a host as a vector

I have the following working code to get IPv4/v6 addresses from host names:

#include <array>
using std::array;

#include <iostream>
using std::cout;

#include <netdb.h>

#include <stdexcept>
using std::domain_error;

#include <sys/socket.h>

#include <string>
using std::string;

#include <vector>
using std::vector;

#include <boost/asio.hpp>
using boost::asio::ip::address;
using boost::asio::ip::address_v4;
using boost::asio::ip::address_v6;

vector<address> getAddresses(string const &hostname)
{
    struct addrinfo req = {.ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM};
    struct addrinfo *pai;
    int error = getaddrinfo(hostname.c_str(), nullptr, &req, &pai);
    if (error)
        throw domain_error("Could not resolve host name.");

    vector<address> addresses;

    for(struct addrinfo *info = pai; info != nullptr; info = info->ai_next) {
        if (info->ai_family == AF_INET) {
            auto ipv4socket = reinterpret_cast<struct sockaddr_in*>(info->ai_addr);
            auto ipv4addr = address_v4(htonl(ipv4socket->sin_addr.s_addr));
            addresses.emplace_back(ipv4addr);
        } else {
            auto ipv6socket = reinterpret_cast<struct sockaddr_in6*>(info->ai_addr);
            auto ipv6base = reinterpret_cast<unsigned char*>(ipv6socket->sin6_addr.s6_addr);
            array<unsigned char, 16> bytearray = {
                ipv6socket->sin6_addr.s6_addr(0),
                ipv6socket->sin6_addr.s6_addr(1),
                ipv6socket->sin6_addr.s6_addr(2),
                ipv6socket->sin6_addr.s6_addr(3),
                ipv6socket->sin6_addr.s6_addr(4),
                ipv6socket->sin6_addr.s6_addr(5),
                ipv6socket->sin6_addr.s6_addr(6),
                ipv6socket->sin6_addr.s6_addr(7),
                ipv6socket->sin6_addr.s6_addr(8),
                ipv6socket->sin6_addr.s6_addr(9),
                ipv6socket->sin6_addr.s6_addr(10),
                ipv6socket->sin6_addr.s6_addr(11),
                ipv6socket->sin6_addr.s6_addr(12),
                ipv6socket->sin6_addr.s6_addr(13),
                ipv6socket->sin6_addr.s6_addr(14),
                ipv6socket->sin6_addr.s6_addr(15)
            };
            auto ipv6addr = address_v6(bytearray, ipv6socket->sin6_scope_id);
            addresses.emplace_back(ipv6addr);
        }
    }

    return addresses;
}

int main()
{
    auto addresses = getAddresses("heise.de");

    for (auto ipa : addresses)
        cout << "Address: " << ipa << "n";

    return 0;
}

I find the conversion fom uint8_t(16) (ipv6socket->sin6_addr.s6_addr) to std::array<unsigned char, 16> a bit verbose.
I also considered doing it in a for-loop, but this would still seem cumbersome to me, somehow.
I tried static_cast and reinterpret_cast to no avail.
Is there a possibility to do this conversion in a simpler way, preferably a one-liner?

Error in plotting vector field

I have a vector plot that plots a directional vector field and colours the arrows using the density. The function is based on parameters $sigma_1$, $sigma_1$ and r.

The problem is that instead of plotting the desired plot the function is plotting an empty plot. From the code below can you identify what I am doing wrong?

p33 =  With({},
  Clear(x, y);
  param = {r -> 1, Subscript((Sigma), 1) -> 2, 
    Subscript((Sigma), 2) -> 1};
  Cm = C3sol /. param;
  vec = ((D3.Inverse(C3sol)/2 - M3).( {
         {x},
         {y}
        } ) // Flatten) /. param;
  VectorPlot(
   vecPDF(MultinormalDistribution({0, 0}, Cm), {x, y}),
   {x, -2, 2}, {y, -2, 2},
   VectorScale -> Small,
   FrameLabel -> {"x", "y"},
   VectorStyle -> Black,
   ColorFunction -> 
    Function({x, y, vx, vy, n}, Blend({White, Gray}, n))
   )
  )

Rust Printing Vector of Numbers from User Input

I am brand new to Rust and want to know if there are any convention violations in my code and ways how I can make it more readable.

let mut arr: Vec<i32> = Vec::new();
loop {
    println!("Enter any number, 0 to terminate");
    let mut num = String::new();
    io::stdin()
        .read_line(&mut num);
    if num.trim().parse::<i32>().unwrap() == 0 {break;}
    arr.push(num.trim().parse::<i32>().unwrap());
}
for v in arr{
    println!("{}", v);
}