c# – Unity Runtime Surface Snapping (Like Shift+Cntrl in Editor)

I am trying to allow the user of my VR game to move objects around using a pointer, then when holding down a button, snap to a grid and align to the highest surface, essentially replicating the Editor behavior or holding down shift+control and moving around a transform gizmo. (Try it, it’s fun!)

I have the grid part down, but can’t wrap my head around how to do the surface snapping.
Here is the code I have so far. I would appreciate any and all help!

// offsetPos is where the VR pointer is.
Vector3 offsetPos = pointer.objectControlPoint.transform.position + cursorOffset;
Vector3 newPos;
if (isSnapping) // Snap to ground code.
// I read previously to do this up then down thing, but It's not working as expected
    RaycastHit groundHit = new RaycastHit();
    if (Physics.Raycast(selectedObject.transform.position, Vector3.down, out groundHit))
         RaycastHit objectHit = new RaycastHit();
         if (Physics.Raycast(groundHit.point, Vector3.up, out objectHit))
                Vector3 snapDiff = groundHit.point - objectHit.point;
                snapYPos = snapDiff.y + (selectedObject.collider.bounds.extents.y);
      // worldGrid is a monoBehavior on another object, and gridCellSize is just a float
      float gridPosX = Mathf.Floor(offsetPos.x / worldGrid.gridCellSize) * worldGrid.gridCellSize;
      float gridPosZ = Mathf.Floor(offsetPos.z / worldGrid.gridCellSize) * worldGrid.gridCellSize;
      newPos = new Vector3(gridPosX, snapYPos, gridPosZ); // Sets the target position to the nearest grid cell, with a Y of the snap position.
else // If not in snap mode, set target position to just the VR cursor.
       newPos = new Vector3(offsetPos.x, offsetPos.y, offsetPos.z);
// I know lerp might not be the most efficient, but I like the smooth effect, and it looks good when snapping to the grid...
selectedObject.transform.position = Vector3.Lerp(selectedObject.transform.position, newPos, movementLerpSpeed * Time.deltaTime);

The objects I need to be snapping all are different sizes and have their origins in different places, but all do have appropriate box colliders.

Thanks so much!

ag.algebraic geometry – How do I find or derive circumspherical radii, surface area, and volume for these 5 non-traditional concave polyhedra?

As much of a mathematics enthusiast I am, I’m stuck on a huge roadblock in further developing my code for the paper that shows the value in different geometries at the nanoscale for nanomedicine: There are five shapes that I am having trouble deriving the circumspherical radii, and thus, the equations of surface area and volume, to solve my equations:

Medial Rhombic Triacontahedron
Medial Triambic Icosahedron
Ditrigonal Dodecadodecahedron
Excavated Dodecahedron

I’ve scoured the internet to find some approximations but the only one I could find was based off of one of those solids so far and it’s not a modifiable equation as I cannot denote where the side length comes into play (they are just constants based off of a unit edge length): http://dmccooey.com/polyhedra/MedialRhombicTriacontahedron.html

I was wondering if anyone knew how to derivate the shape’s equations or where I can find the correct resource? I’d derivate it myself but it’s a bit above my scope of knowledge. I need a physical solid to cut and manipulate to try to find basic ratios at the very least.

convex geometry – The surface area measure in terms of support functions

$defRR{mathbb{R}}$Let $K$ be a closed bounded convex body in $RR^n$. The support function $h_K$ on $RR^n$ is defined by
$$h_K(v) = max_{w in K} langle v,w rangle.$$

Let $S^{n-1}$ be the unit sphere. The surface area measure is the measure on $sigma$ such that, for an open set $U$ in $S^{n-1}$, the measure $sigma(U)$ is the $(n-1)$-dimensional Lebesgue measure of the set of $w in partial K$ where at which supporting hyperplanes normal to $v$ make contact. (I believe this is fairly standard terminology; I am reading Schneider’s “Convex Bodies
The Brunn-Minkowski Theory” as my reference.)

Now, if $K$ is smooth, then $sigma$ is a smooth $(n-1)$-form, and we can compute $tfrac{sigma}{mathrm{Area}}$ in terms of the Hessian of $h$. Namely, restrict $h$ to the affine hyperplane $v+v^{perp}$. (In other words, the tangent plane to $S^{n-1}$ at $v$.) Then $tfrac{sigma}{mathrm{Area}}$ is the determinant of the Hessian of this restricted function.

On the other hand, suppose that $K$ is a polytope, so $h$ is piecewise linear. Then $sigma$ is an atomic measure, concentrated on the normals to the facets of $K$. Then we can also compute $sigma$ in terms of $h$ restricted to $v+v^{perp}$: For $u$ in $v^{perp}$, take the directional derivative $tilde{h}(u) := lim_{t to 0^+} tfrac{h(v+tu)-h(v)}{t}$. Then $tilde{h}(u)$ is (I believe) the support function of the facet normal to $v$, and $sigma(v)$ is the volume of that facet.

What I am trying to understand is how to interpolate between these formulas. In general, is $sigma$ something in terms of the restriction of $h$ to $v+v^{perp}$. And why am I seeing second derivatives in the smooth case and first (directional) derivatives in the polytopal case?

gn.general topology – Can the infinite jungle gym surface be expressed by canonical exhaustions?

Is it possible to write the infinite jungle gym surface as the increasing union of compact surfaces whose boundaries consist of only one simple closed curve? I believe that this is true. It is well know that this surface has only one end. Therefore the result should follow from the existence of canonical exhaustions (as explained in Ahlfors-Sario book). If anyone could help me, I would like to “see” such a curve. Thanks.

wallet.dat – Search and delete bitcoin core and other related files to reduce attack surface

  1. No

  2. No. What happens to wallet.dat if I uninstall and re-install on Windows Bitcoin desktop client?

  3. Depends on the user and it’s good to delete such files from system that will not be used anymore if you have backup.

Scanning bitcoin core related important files with an open source tool: https://github.com/deepfence/SecretScanner

It will search for lot of files including 3 related to Bitcoin Core:

  - part:  'filename'
    match: 'wallet.dat'
    name: 'Bitcoin Core wallet'
  - part:  'filename'
    match: 'onion_v3_private_key'
    name: 'Private key for Bitcoin Core onion service'
  - part:  'filename'
    match: 'bitcoin.conf'
    name: 'Bitcoin Core config'


Maybe we can even add debug.log in this.

A blog post about “Detecting secrets to reduce attack surface”: https://medium.com/deepfence-cloud-native-security/detecting-secrets-to-reduce-attack-surface-3405ee6329b5


Secrets are as important as vulnerabilities from cybersecurity point of view, as attackers can very easily get backdoor access into customer infrastructure and spread laterally to launch multi-stage attacks due to leakage of secrets.

probability distributions – Lebesgue measure of a circular arc on the surface of the hypersphere

The following sub-problem came up in one of my research works:

Suppose that $U$ is a uniform random variable on the surface of the $d$-dimensional sphere with center at the origin and of radius $r$. Also, let $v$ be an arbitrary vector in $mathbb{R}^d$. What is the exact value (or maybe a good approximation) of the following probability?

$$mathbb{P}(v^top U > c) $$

You may assume that $c$ is any real number less than the trivial Cauchy-Schwarz bound $r|v|$. Of course the set ${x in mathbb{R}^d: |x|=r~,~v^top x > c}$ is a circular arc (portion) on the surface of the sphere in $mathbb{R}^d$ with radius $r$, so the problem essentially boils down to calculating the Lebesgue measure of this circular portion on the sphere, but it seems that I am not able to get an exact answer for this. Any help will be greatly appreciated!

Is it always possible to extend a homeomorphism from a closed ball in the plane onto a closed disk in a surface to their neighbourhoods?

Let $S$ be a two dimensional surface and $D$ a closed disk contained in $S$. Is it true that if $f$ is a homeomorphism from a closed ball $B$ in the plane onto $D$, then $f$ extends to a homeomorphism from a neighbourhood of $B$ in the plane onto a neighbourhood of $D$ in the surface?

Why is the genus (in terms of Euler the maximum number of simple closed curves that can be embedded in the surface without disconnecting it?

Let $S$ be a compact surface and $g$ its genus defined in terms of Euler characteristic.
Why is $g$ the maximum number of simple closed curves that can be embedded in the surface without disconnecting it?
I would be grateful if anyone could tell me how to prove it or give me a reference. Thanks.

Quintic surface singular along lines

What is the maximum number of lines, along which a quintic surface in $mathbb{P}^3$ can be singular ?

bullet physics – How to move a player on a sphere surface using Ammo.js and Three,js

I am moving a rigidbody (the character) on the surface of a sphere, like what is described here.

I am facing the following issue that I am having hard time to solve:
After moving the character, it starts spinning really slightly around it’s Y axis.

As a side note, I am using Ammo.js which is a javascript/webassembly port of Bullet 2.82, but this has no impact on the problem.

To “stick” the player (a dynamic rigidbody with a cylinder shape) to the sphere (a static rigid body with a sphere shape), here is the code, called on each game loop iteration:

function applyAttraction() {
    let sphereOrigin = this.body.getWorldTransform().getOrigin();
    let characterOrigin = this._characterEntity.body.getWorldTransform().getOrigin();

    // compute and apply sphere gravity to character body
    let sphereAttractionForce = new ammo.btVector3(
      characterOrigin.x() - sphereOrigin.x(),
      characterOrigin.y() - sphereOrigin.y(),
      characterOrigin.z() - sphereOrigin.z()
    this._characterEntity.body.applyForce(sphereAttractionForce, ammo.btVector3(0, 0, 0));

    // align character up with sphere origin
    const gravityDirection = bt2ThreeVec3(sphereAttractionForce).normalize().multiplyScalar(-1);

    // extract up axis of character transform basis
    let characterUp = new THREE.Vector3();
      new THREE.Vector3(),
      new THREE.Vector3()

    // apply rotation to align up with gravity vector
    let verticalAlignmentRotation = new Quaternion()
      .setFromUnitVectors(characterUp, gravityDirection)


And to move the character on the sphere (I removed the code dealing with the mouse controlled orientation since it is irrelevant to track down the problem). This code is also called on every game loop iteration:

let scalingFactor = 0.02;
    let moveX = inputController.getMoveX();
    let moveZ = inputController.getMoveZ();

    if (moveX === 0 && moveZ === 0) return;

    let movement = new THREE.Vector3(moveX, 0, moveZ).normalize();
    let wantedWorldPos = this.graphic.localToWorld(movement);
      .setOrigin(new ammo.btVector3(wantedWorldPos.x, wantedWorldPos.y, wantedWorldPos.z));

In plain (approximative) English, what I am doing:

  1. Get the direction from the player position to the center of the sphere
  2. Apply a force using that vector: this._characterEntity.body.applyForce(sphereAttractionForce, ammo.btVector3(0, 0, 0));
  3. Align the player Up with the gravity direction, to do so I:
    1. normalize and “flip” gravity vector direction
    2. extract character up vector and compute the quaternion which give the rotation to align this up vector with the gravity vector
    3. compute the new player orientation by applying quaternion from 3.2 to it’s current orientation
  4. Apply movement (from keyboard inputs), in details:
    1. get a vector resulting from the requested movement alongside x and z axis
    2. convert this vector from player local basis to world basis: this.graphic.localToWorld(movement);
    3. set the new transform origin with this new vector

The project may be seen here (with the spinning issue I am describing). You may need to move a bit on the sphere (with WASD keys).