3D AxisAngle spins at 180 degrees

I am using the Axis Angle technique on objects so that they are oriented away from a planet surface like in Super Mario Galaxy. I am using two unit vectors [0,1,0] and a normal vector from the planet. Is there any way to stop the 3D objects from spinning when they go near 180 degrees and still orient correctly? Could I use gimbal lock to fix it? This is what I have so far for my game in JavaScript:

// Angles are in radians angle = Math.acos(dotProductVec3([0,1,0], forceNormal));  // Using two unit vectors to find the axis and angle     if (angle > Math.PI / 2) {     forceRotation.angle = Math.acos(dotProductVec3([0,-1,0], forceNormal));     forceRotation.axis = vec3Normalize(vec3CrossProduct([0,-1,0], forceNormal)); } else {     forceRotation.angle = Math.acos(dotProductVec3([0,1,0], forceNormal));     forceRotation.axis = vec3Normalize(vec3CrossProduct([0,1,0], forceNormal)); } 

Above I am using a negative number on the y axis to stop the spin when 180 degrees has been reached. The problem is the objects point towards the planet rather than away. Also I have tried Quaternions but they seem to spin too.

How can I rotate the player only to -40 or -45 degrees?

float c = 0.0f; private void FixedUpdate() {     if (startRotatingBack)     {         var p = transform.eulerAngles;          if (p.y != -40)         {             p.y -= 1;             transform.eulerAngles = p;         }          c = c + 0.1f;         playerAnimator.SetFloat("Forward", c);     } } 

The problem is that the transform keeps rotating nonstop.

Maybe the problem is with this chick?

if (p.y != -40) 

I want to make that the player will rotate backward. -40 or -45 is good enough but the player the transform is eep rotating nonstop so it’s making circles instead of rotating once to -40 or to -45.

Can Mathematica factor multivariate polynomials with 4 or more variables? And with high degrees (>10)

The Mathematica documentation clearly states

the Wolfram Language routinely factors degree-100 polynomials in 3 variables

I’m interested in factoring systems of polynomials in as many as 10 or 20 variables. The systems I have are sparse in the sense that if there are 20 variables then likely no more than 3-6 variables will appear per equation and there will likely only be two terms per equation. I’ve used Solve to test on some small systems with success. To be clear, we don’t actually need to factor the polynomials necessarily. If we factor them, then we have what we need. What we really want are the roots to the system with respect to the symbolic coefficients. Solve worked for some small test systems. Factor would also work for a single polynomial, but we need a system of polynomials and I don’t see that Factor will take a system.

I’ve looked at papers by searching scholar.google.com and it seems our problem is a solved problem in mathematics. Algorithms seem to exist for such a problem, but I’m even unclear on this since the papers are too densely packed with math for me to easily understand.

Any help would be appreciated.

How to handle degrees of success in roll under systems

I’m working on an RPG system that uses 2d6 roll under Skill for resolutions. On paper this system looks really good so far, but I have one major issue: Degrees of Success, especially when it comes to Contest (Skill vs Skill) resolutions.

Status Quo

Your character’s Attribute + Skill (e.g. Charisma + Persuasion) form a Target Number that’s between 2 and 12. You roll 2d6, sum them, and the sum has to be equal to or lower than the Target Number. Rolling a 1 has a special positive meaning, rolling a 6 has a special negative meaning. Additionally, 2 ones are always a success, 2 sixes are always a failure, regardless of Skill.

The problem

Imagine 2 parties contesting each other:

  • Character A has a Target Number of 5 (pretty bad), and character B has a Target Number of 10 (pretty good).
  • Character A rolls a 5 and succeeds. Character B and rolls a 6 and succeeds.
  • Character B has the better Degree of Success, as the margin between the player’s roll and the character’s Skill is bigger than for Character A.

If you say that lower is better, a character with Target Number 2 (very, very bad), who rolled a 2, will always have a better Degree of Success over a character with a Target Number 12 (very, very good), who rolled a 3.

Naive solution

My approach was to subtract the rolled number from the character’s Skill. You have a Target Number of 6 and rolled a 4? 6-4=2. You have a Target Number of 11 and rolled a 3? 11-3=8. It works, but I’m worried that this resolution will be too slow for actual play – we all know these sessions that last for hours and nobody is able to count straight anymore.

The best solution would allow a player to determine the Degree of Success/Failure in the same step to see if the character succeeded or not.

Other systems

Other systems that handle Degrees of Success for rolling under mechanics:

  • Call of Cthulhu: You have certain threesholds (half your skill, 1/5 your skill) at which you score an increased Degree of Success. – very coarse when you only have 2d6 instead of a 1d100 (but could work)
  • Unknown Armies: Basically like Black Jack–you roll under your Skill threshold, but as high as possible. Doubles (11, 22, 33) are criticals. – sadly doesn’t work, as ones and sixes have a special meaning. Flipping the meaning (6 is good, 1 is bad) also is iffy, as it’s flipping the understanding, that you have to roll under a threshold.
  • ???

What other systems or resolution systems are there, that tackle this problem?

Are there guidelines for how to narrate different degrees of success/failure?

I find myself getting caught up in a story and sometimes when players roll skill checks I give them the information or allow for a success depending on several factors(their description, their character, my mood, whether it adds to the story or adds flair), I’d like to be able to start keeping skill check descriptions more consistent.

For example:

Let’s say I have a player at the table that loves to blackflip, and depending on the situation that DC changes, for instance difficult terrain might make it harder where just walking through the streets of a well laid out city it would be easier.

For all intents and purposes let’s say there’s no additional DC and a backflip is a 10, so the character rolls and gets a 9.

I say “Well you feel like you have it and just at the last moment your foot lands sideways and you fall.”

Or I have players investigating a room, there’s a secret door that has a DC 15 investigation check on it. My player rolls a 14, I say “You take note that someone was recently in the room, and some papers are shuffled on the desk.”

Should I simply set my DC for things and then pass/fail? Is there anything I might be able to reference for this?

How do criticals interact with degrees of success for attacks in PF2E?

Let’s say my character Strikes an enemy with AC 40. My attack bonus is only +10, so barring crits, it’s impossible for me to get through his AC.

I roll a natural 20, making my total 30 vs his 40 AC. Is this attack treated as a regular hit, because it would have been a failure but the nat 20 improves the degree of success by one step? Or is it treated as a critical hit, because it’s a nat 20?

Similarly, if I’m subjected to a spell with a saving throw I can only fail at, and I roll a nat 20, does that mean I reach a success on the saving throw or a critical success?

Is it possible to work out rotate in degrees per second based on this rotate logic?

I have this code to rotate an object towards another at a given speed.

    /// <summary>     /// Rotate towards the target.     /// </summary>     /// <param name="lookPosition"></param>     private void RotateTowardsTarget(Vector3 lookPosition)     {         // Determine which direction to rotate towards         Vector3 targetDirection = lookPosition - transform.position;          // The step size is equal to speed times frame time.         float singleStep = weaponRotationSpeed * Time.deltaTime;          // Rotate the forward vector towards the target direction by one step         Vector3 newDirection =             Vector3.RotateTowards(turretYRotation.transform.forward, targetDirection, singleStep, 0.0f);          // Draw a ray pointing at our target in         //Debug.DrawRay(turretYRotation.transform.position, newDirection, Color.red, 3);          newDirection.y = 0;         // Calculate a rotation a step closer to the target and applies rotation to this object         turretYRotation.transform.rotation = Quaternion.LookRotation(newDirection);     } 

And I’d like to convert this to a “Degrees per second” to give the user useful feedback on how quickly it rotates. Is there a formulae I can apply to work it out?