# Solved- How to rotate player using Dot product of two vectors

Advertisements I got it working, I was overcomplicating things by using the Mathf.Cos function, because the Dot product is the cosign of the angle, so I’m not sure what i was thinking. here is the working code for anyone curious. camRotation = player.transform.rotation.x + player.transform.rotation.y * Input.mousePosition.x + Input.mousePosition.y; player.transform.rotation = Quaternion.Euler(0, 0, camRotation); >Solution… Read More Solved- How to rotate player using Dot product of two vectors

# How to rotate a triangle about it's center?

Advertisements document.onkeydown = function (event) { switch (event.keyCode) { case 74: //player presses "j" px = player.calculateCentreX(); py = player.calculateCentreY(); x1 = rotateX(player.x1,player.y1,35,px,py); x2 = rotateX(player.x2,player.y2,35,px,py); x3 = rotateX(player.x3,player.y3,35,px,py); y1 = rotateY(player.x1,player.y1,35,px,py); y2 = rotateY(player.x2,player.y2,35,px,py); y3 = rotateY(player.x3,player.y3,35,px,py); player.setPoints(x1,y1,x2,y2,x3,y3); break; default: break; } }; function rotateX(cx,cy,angle,px,py) { x = Math.cos(angle)*(px-cx) – Math.sin(angle)*(py-cy) + cx return… Read More How to rotate a triangle about it's center?

# solving nested renamer is not supported with dynamic arguments

Advertisements if cat_vars: df["static_cat"] = ( df.groupby("group_col") .agg({i: "first" for i in cat_vars}) .values.tolist() ) Error: packages\pandas\core\groupby\generic.py in aggregate(self, func, *args, **kwargs) 926 func = _maybe_mangle_lambdas(func) 927 –> 928 result, how = self._aggregate(func, *args, **kwargs) 929 if how is None: 930 return result packages\pandas\core\base.py in _aggregate(self, arg, *args, **kwargs) 355 obj.columns.intersection(keys) 356 ) != len(keys):… Read More solving nested renamer is not supported with dynamic arguments

# How to add borders for SnackBar in Flutter?

Advertisements I’m doing system messages, I decided to use SnackBar, but I ran into a problem – I can’t add a border around the SnackBar, I need to make a colored border. Please tell me, is it possible to add a border to the SnackBar and how? Perhaps there are packages that allow you to… Read More How to add borders for SnackBar in Flutter?

# placing images on a pygame grid

Advertisements The red and blue sides would each have their tiles replaced by an image (not one image overlapping them all, but one image pasted onto each tile). I’m not really sure how to go about it, and any help would be appreciated! import pygame TILESIZE = 22 margin = 1 BOARD_POS = (10, 10)… Read More placing images on a pygame grid

# Python replacing all list elements instead of the indexed list element in for loop

Advertisements I want to replace the kth element of the kth element of the list. E.g., [[0, 0, 0], [0, 0, 0], [0, 0, 0]] to [[1, 0, 0], [0, 1, 0], [0, 0, 1]] BUT python does not seem to want to do that and instead is replacing each value for each element. I… Read More Python replacing all list elements instead of the indexed list element in for loop

# For Loop In R not working with Plot function

Advertisements I Am trying out a way to figure out how i could print multiple plots at once with a for loop , as i am super new to R i can’t seem to find a way to do this I Have 40 Principle components that i would like to plot through for loop, but… Read More For Loop In R not working with Plot function

# Displaying percentages within category for continuous/ordered variable (with ggplot)

Advertisements I have two questions, the first a (hopefully) straightforward mechanical one and the second more theoretical (though still with a technical element). I am trying to do something nearly identical to this question, but I have a variable that is ordered/continuous (0 – 4), instead of a 1/0 dichotomous variable, which means that filtering… Read More Displaying percentages within category for continuous/ordered variable (with ggplot)

# How can I toggle this dropdown?

Advertisements I have tried adding a simple toggle function to the dropdown-btn class which in turn adds the active class (which is set to display: block;) onto the ul class, am I doing anything wrong here? https://jsfiddle.net/q45yc3vt/10/ HTML <nav class="admin-sidebar sidebar"> <div class="sidebar-nav"> <li><a href="#" class="dropdown-btn"><i class="fas fa-address-card"></i><span>Dropdown</span><i class="fas fa-angle-down"></i></a></li> <ul class="options"> <li>Option 1</li> <li>Option… Read More How can I toggle this dropdown?