vector

How to destroy a HARFANG object from a scene?

How to destroy a HARFANG object from a scene? Question: I would like to know how to destroy an object from a HARFANG scene? I’m using the Python HG API I tried calling hg.DestroyObject(Object) and scene.DestroyObject(Object) but both failled. Should I call the method differently or is my object referenced incorrectly (the object was created …

Total answers: 1

How to calculate the rotation angles needed on X and Z to align two vectors

How to calculate the rotation angles needed on X and Z to align two vectors Question: I am trying to rotate vector1 (red) so that it aligns with vector2 (blue) in 3D space. However, only rotations around the X and Z axis should be used. So far, I have solved this using an optimizing algorithm …

Total answers: 1

Getting an Array/Vector from PARI/GP in Python using Ctypes

Getting an Array/Vector from PARI/GP in Python using Ctypes Question: I have written a code to compare the solution of sympy and PARI/GP, how ever I am facing a problem to get an array/vector from PARI/GP. When I try to return the vector res from PARI/GP function nfroots, I get a address like this (see …

Total answers: 1

How to compare sentence similarities using embeddings from BERT

How to compare sentence similarities using embeddings from BERT Question: I am using the HuggingFace Transformers package to access pretrained models. As my use case needs functionality for both English and Arabic, I am using the bert-base-multilingual-cased pretrained model. I need to be able to compare the similarity of sentences using something such as cosine …

Total answers: 5

Slicing a vector in C++

Slicing a vector in C++ Question: Is there an equivalent of list slicing [1:] from Python in C++ with vectors? I simply want to get all but the first element from a vector. Python’s list slicing operator: list1 = [1, 2, 3] list2 = list1[1:] print(list2) # [2, 3] C++ Desired result: std::vector<int> v1 = …

Total answers: 6

pandas timestamp series to string?

pandas timestamp series to string? Question: I am new to python (coming from R), and I am trying to understand how I can convert a timestamp series in a pandas dataframe (in my case this is called df[‘timestamp’]) into what I would call a string vector in R. is this possible? How would this be …

Total answers: 3

How to plot vectors in python using matplotlib

How to plot vectors in python using matplotlib Question: I am taking a course on linear algebra and I want to visualize the vectors in action, such as vector addition, normal vector, so on. For instance: V = np.array([[1,1],[-2,2],[4,-7]]) In this case I want to plot 3 vectors V1 = (1,1), M2 = (-2,2), M3 …

Total answers: 8

Distance between point and a line (from two points)

Distance between point and a line (from two points) Question: I’m using Python+Numpy (can maybe also use Scipy) and have three 2D points (P1, P2, P3); I am trying to get the distance from P3 perpendicular to a line drawn between P1 and P2. Let P1=(x1,y1), P2=(x2,y2) and P3=(x3,y3) In vector notation this would be …

Total answers: 9

Get the magnitude of a vector (x,y)

Get the magnitude of a vector (x,y) Question: I’m struggling to get this to work because all the answers I can find that most answers are more focused on vectors in numpy arrays and not like mine in classes (OOP). (I hope I am phrasing all this the correct way, please excuse if I am …

Total answers: 3