Skip to content

Instantly share code, notes, and snippets.

@LennyLizowzskiy
LennyLizowzskiy / ComposedInputMethodService.kt
Created June 5, 2023 12:57
Android InputMethodService implementation that allows to build IME UI via Jetpack Compose
import android.content.Intent
import android.inputmethodservice.InputMethodService
import android.view.View
import androidx.annotation.CallSuper
import androidx.compose.ui.platform.AbstractComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ServiceLifecycleDispatcher
import androidx.lifecycle.ViewModelStore
@cuongmzq
cuongmzq / atan2_approximation.c
Created February 13, 2021 11:58 — forked from volkansalma/atan2_approximation.c
optimized atan2 approximation
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float atan2_approximation1(float y, float x);
float atan2_approximation2(float y, float x);
int main()
{
float x = 1;
@cuongmzq
cuongmzq / ConfigurableJointExtensions.cs
Created August 20, 2020 17:02 — forked from mstevenson/ConfigurableJointExtensions.cs
Unity extension methods for computing a ConfigurableJoint.TargetRotation value from a given local or world rotation.
using UnityEngine;
public static class ConfigurableJointExtensions {
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
if (joint.configuredInWorldSpace) {
@cuongmzq
cuongmzq / PhysicsHelper.cs
Created August 20, 2020 17:02 — forked from ditzel/PhysicsHelper.cs
Unity Helper for Physic Functions
using UnityEngine;
namespace Ditzelgames
{
public static class PhysicsHelper
{
public static void ApplyForceToReachVelocity(Rigidbody rigidbody, Vector3 velocity, float force = 1, ForceMode mode = ForceMode.Force)
{
if (force == 0 || velocity.magnitude == 0)
class PoolObject {
constructor(data) {
this.data = data;
this.nextFree = null;
this.previousFree = null;
}
}
class Pool {
constructor(objCreator, objReseter, initialSize = 5000) {
@ditzel
ditzel / PhysicsHelper.cs
Created January 20, 2019 16:54
Unity Helper for Physic Functions
using UnityEngine;
namespace Ditzelgames
{
public static class PhysicsHelper
{
public static void ApplyForceToReachVelocity(Rigidbody rigidbody, Vector3 velocity, float force = 1, ForceMode mode = ForceMode.Force)
{
if (force == 0 || velocity.magnitude == 0)
@jackmott
jackmott / RotatedRectangle.cs
Created October 11, 2017 14:06
Rotated rectangle collision detection
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
//Faster linq-style convenience functions https://github.com/jackmott/LinqFaster
using JM.LinqFaster;
namespace DrawAndDrive
{
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Last active April 22, 2025 13:06
Unity extension methods for computing a ConfigurableJoint.TargetRotation value from a given local or world rotation.
using UnityEngine;
public static class ConfigurableJointExtensions {
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
if (joint.configuredInWorldSpace) {
@volkansalma
volkansalma / atan2_approximation.c
Created June 22, 2012 11:35
optimized atan2 approximation
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float atan2_approximation1(float y, float x);
float atan2_approximation2(float y, float x);
int main()
{
float x = 1;
@geraldyeo
geraldyeo / fastTrig.as
Created May 24, 2011 03:52
Fast and accurate sine/cosine approximation
//1.27323954 = 4/pi
//0.405284735 =-4/(pi^2)
/*********************************************************
* low precision sine/cosine
*********************************************************/
//always wrap input angle to -PI..PI
if (x < -3.14159265)
x += 6.28318531;